Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-01-21 22:09:17
Exec Total Coverage
Lines: 1719 3953 43.5%
Functions: 126 338 37.3%
Branches: 925 2720 34.0%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for Zelda Classic.
9 //
10 //--------------------------------------------------------
11
12 // to prevent <map> from generating errors
13 #define __GTHREAD_HIDE_WIN32API 1
14
15 #include "precompiled.h" //always first
16 #include "zc_sys.h"
17
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <math.h>
22 #include <map>
23 #include <filesystem>
24 #include <ctype.h>
25 #include <sstream>
26 #include "base/zc_alleg.h"
27 #include "gamedata.h"
28 #include "zc_init.h"
29 #include "init.h"
30 #include "replay.h"
31 #include "cheats.h"
32 #include "render.h"
33 #include "base/zc_math.h"
34 #include "base/zapp.h"
35
36 #ifdef ALLEGRO_DOS
37 #include <unistd.h>
38 #endif
39
40 #include "metadata/metadata.h"
41 #include "zelda.h"
42 #include "tiles.h"
43 #include "base/colors.h"
44 #include "pal.h"
45 #include "base/zsys.h"
46 #include "qst.h"
47 #include "zc_sys.h"
48 #include "play_midi.h"
49 #include "debug.h"
50 #include "jwin.h"
51 #include "base/jwinfsel.h"
52 #include "base/gui.h"
53 #include "midi.h"
54 #include "subscr.h"
55 #include "maps.h"
56 #include "sprite.h"
57 #include "guys.h"
58 #include "hero.h"
59 #include "title.h"
60 #include "particles.h"
61 #include "zconsole.h"
62 #include "ffscript.h"
63 #include "dialog/info.h"
64 #include "dialog/alert.h"
65 #include <fmt/format.h>
66
67 #ifdef __EMSCRIPTEN__
68 #include "base/emscripten_utils.h"
69 #endif
70
71 extern FFScript FFCore;
72 extern bool Playing;
73 int32_t sfx_voice[WAV_COUNT];
74 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
75 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
76
77 extern byte monochrome_console;
78
79 extern FONT *lfont;
80 extern HeroClass Hero;
81 extern FFScript FFCore;
82 extern ZModule zcm;
83 extern zcmodule moduledata;
84 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
85 extern particle_list particles;
86 extern int32_t loadlast;
87 extern word passive_subscreen_doscript;
88 extern bool passive_subscreen_waitdraw;
89 byte use_dwm_flush;
90 byte use_save_indicator;
91 byte midi_patch_fix;
92 bool midi_paused=false;
93 int32_t paused_midi_pos = 0;
94 byte midi_suspended = 0;
95 byte callback_switchin = 0;
96 byte zc_192b163_warp_compatibility;
97 char modulepath[2048];
98 byte epilepsyFlashReduction;
99 signed char pause_in_background_menu_init = 0;
100 byte pause_in_background = 0;
101 bool is_sys_pal = false;
102 extern PALETTE* hw_palette;
103 extern bool update_hw_pal;
104 extern const char* dmaplist(int32_t index, int32_t* list_size);
105
106
107 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
108 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
109 //extern byte refresh_select_screen;
110 //extern movingblock mblock2; //mblock[4]?
111 //extern int32_t db;
112
113 static const char *ZC_str = "Zelda Classic";
114 extern char save_file_name[1024];
115 #ifdef ALLEGRO_DOS
116 const char *qst_dir_name = "dos_qst_dir";
117 #elif defined(ALLEGRO_WINDOWS)
118 const char *qst_dir_name = "win_qst_dir";
119 static const char *qst_module_name = "current_module";
120 #elif defined(ALLEGRO_LINUX)
121 const char *qst_dir_name = "linux_qst_dir";
122 static const char *qst_module_name = "current_module";
123 #elif defined(__APPLE__)
124 const char *qst_dir_name = "osx_qst_dir";
125 static const char *qst_module_name = "current_module";
126 #endif
127 #ifdef ALLEGRO_LINUX
128 static const char *samplepath = "samplesoundset/patches.dat";
129 #endif
130 char qst_files_path[2048];
131
132 #ifdef _MSC_VER
133 #define getcwd _getcwd
134 #endif
135
136 bool rF11();
137 bool rI();
138 bool rQ();
139 bool zc_key_pressed();
140
141 #ifdef _WIN32
142
143 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
144 extern "C"
145 {
146 typedef HRESULT(WINAPI *t_DwmFlush)();
147 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
148 }
149
150 void do_DwmFlush()
151 {
152 static HMODULE shell = LoadLibrary("dwmapi.dll");
153
154 if(!shell)
155 return;
156
157 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
158 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
159
160 BOOL enabled;
161 isEnabled(&enabled);
162
163 if(isEnabled)
164 flush();
165 }
166
167 #endif // _WIN32
168
169 // Dialogue largening
170 void large_dialog(DIALOG *d)
171 {
172 large_dialog(d, 1.5);
173 }
174
175 void large_dialog(DIALOG *d, float RESIZE_AMT)
176 {
177 if(!d[0].d1)
178 {
179 d[0].d1 = 1;
180 int32_t oldwidth = d[0].w;
181 int32_t oldheight = d[0].h;
182 int32_t oldx = d[0].x;
183 int32_t oldy = d[0].y;
184 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
185 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
186 d[0].w = int32_t(d[0].w*RESIZE_AMT);
187 d[0].h = int32_t(d[0].h*RESIZE_AMT);
188
189 for(int32_t i=1; d[i].proc !=NULL; i++)
190 {
191 // Place elements horizontally
192 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
193 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
194
195 if(d[i].proc != d_stringloader)
196 {
197 if(d[i].proc==d_bitmap_proc)
198 {
199 d[i].w *= 2;
200 }
201 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
202 }
203
204 // Place elements vertically
205 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
206 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
207
208 // Vertically resize elements
209 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
210 {
211 d[i].h = int32_t((double)d[i].h*1.5);
212 }
213 else if(d[i].proc == jwin_droplist_proc)
214 {
215 d[i].y += int32_t((double)d[i].h*0.25);
216 d[i].h = int32_t((double)d[i].h*1.25);
217 }
218 else if(d[i].proc==d_bitmap_proc)
219 {
220 d[i].h *= 2;
221 }
222 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
223
224 // Fix frames
225 if(d[i].proc == jwin_frame_proc)
226 {
227 d[i].x++;
228 d[i].y++;
229 d[i].w-=4;
230 d[i].h-=4;
231 }
232 }
233 }
234
235 for(int32_t i=1; d[i].proc!=NULL; i++)
236 {
237 if(d[i].proc==jwin_slider_proc)
238 continue;
239
240 // Bigger font
241 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
242
243 if(!d[i].dp2 && bigfontproc)
244 {
245 //d[i].dp2 = (d[i].proc == jwin_edit_proc) ? sfont3 : lfont_l;
246 d[i].dp2 = lfont_l;
247 }
248 else if(!bigfontproc)
249 {
250 // ((ListData *)d[i].dp)->font = &sfont3;
251 ((ListData *)d[i].dp)->font = &lfont_l;
252 }
253
254 // Make checkboxes work
255 if(d[i].proc == jwin_check_proc)
256 d[i].proc = jwin_checkfont_proc;
257 else if(d[i].proc == jwin_radio_proc)
258 d[i].proc = jwin_radiofont_proc;
259 }
260
261 jwin_center_dialog(d);
262 }
263
264
265 /**********************************/
266 /******** System functions ********/
267 /**********************************/
268
269 static char cfg_sect[] = "zeldadx"; //We need to rename this.
270 static char ctrl_sect[] = "Controls";
271 static char sfx_sect[] = "Volume";
272
273 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
274 {
275 return D_O_K;
276 }
277
278 23 void load_game_configs()
279 {
280 23 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
281 23 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
282 23 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
283 23 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
284 23 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
285 23 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
286 23 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
287 23 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
288 23 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
289 23 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
290 23 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
291 23 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
292 23 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
293 23 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
294 23 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
295
296 //cheat modifier keya
297 23 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
298 23 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
299 23 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
300 23 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
301
302
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
303 joystick_index = 0;
304
305 23 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
306 23 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
307 23 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
308 23 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
309 23 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
310 23 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
311 23 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
312 23 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
313 23 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
314 23 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
315
316 23 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
317 23 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
318 23 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
319 23 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
320
321 23 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
322 23 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
323 23 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
324 23 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
325 23 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
326 23 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
327 23 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
328 23 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
329 23 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
330 23 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
331 23 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
332
333 23 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
334 23 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
335 23 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
336 23 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
337
338 23 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
339
340 23 digi_volume = zc_get_config(sfx_sect,"digi",248);
341 23 midi_volume = zc_get_config(sfx_sect,"midi",255);
342 23 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
343 23 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
344 23 pan_style = zc_get_config(sfx_sect,"pan",1);
345 // 1 <= zcmusic_bufsz <= 128
346 23 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
347 23 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
348 23 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
349 23 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
350 23 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
351 23 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
352 23 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
353 #ifdef __EMSCRIPTEN__
354 if (em_is_mobile()) NameEntryMode = 2;
355 #endif
356 23 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
357 23 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
358 23 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
359 23 title_version = zc_get_config(cfg_sect,"title",2);
360 23 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
361 23 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
362
363 //default - scale x2, 640 x 480
364 23 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
365 23 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
366 23 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
367 23 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
368 23 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
369
370 23 loadlast = zc_get_config(cfg_sect,"load_last",0);
371
372 23 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
373
374 23 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
375
376 //workaround for the 100% CPU bug. -Gleeok
377 #ifdef ALLEGRO_MACOSX //IIRC rest(0) was a mac issue fix.
378 frame_rest_suggest = (byte) zc_get_config(cfg_sect,"frame_rest_suggest",0);
379 #else
380 23 frame_rest_suggest = (byte) zc_get_config(cfg_sect,"frame_rest_suggest",1);
381 #endif
382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 frame_rest_suggest = zc_min(2, frame_rest_suggest);
383
384 23 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
385
386 #ifdef _WIN32
387 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
388 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
389 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
390 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
391
392 // This one's for Aero
393 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
394
395 // And this one fixes patches unloading on some MIDI setups
396 midi_patch_fix = (byte) zc_get_config("zeldadx","midi_patch_fix",1);
397 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
398 #else //UNIX
399 23 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
400 23 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
401 23 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
402 #endif
403 23 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
404
405 23 char const* default_path = "";
406 23 strcpy(qstdir,zc_get_config(cfg_sect,qst_dir_name,default_path));
407
408
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(strlen(qstdir)==0)
409 {
410 23 getcwd(qstdir,2048);
411 23 fix_filename_case(qstdir);
412 23 fix_filename_slashes(qstdir);
413 23 put_backslash(qstdir);
414 23 }
415 else
416 {
417 chop_path(qstdir);
418 }
419
420 23 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
421 23 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
422 23 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
423 23 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
424 23 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
425 23 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
426 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
427 23 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
428 23 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
429 23 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
430 23 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
431 23 }
432
433 void save_control_configs(bool kb)
434 {
435 if(kb)
436 {
437 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
438 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
439 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
440 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
441
442 if (!replay_is_replaying())
443 {
444 zc_set_config(ctrl_sect,"key_a",Akey);
445 zc_set_config(ctrl_sect,"key_b",Bkey);
446 zc_set_config(ctrl_sect,"key_s",Skey);
447 zc_set_config(ctrl_sect,"key_l",Lkey);
448 zc_set_config(ctrl_sect,"key_r",Rkey);
449 zc_set_config(ctrl_sect,"key_p",Pkey);
450 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
451 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
452 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
453 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
454 zc_set_config(ctrl_sect,"key_up", DUkey);
455 zc_set_config(ctrl_sect,"key_down", DDkey);
456 zc_set_config(ctrl_sect,"key_left", DLkey);
457 zc_set_config(ctrl_sect,"key_right",DRkey);
458 }
459 }
460 else
461 {
462 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
463 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
464 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
465 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
466 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
467 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
468 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
469 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
470 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
471 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
472 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
473 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
474 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
475 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
476
477 zc_set_config(ctrl_sect,"btn_a",Abtn);
478 zc_set_config(ctrl_sect,"btn_b",Bbtn);
479 zc_set_config(ctrl_sect,"btn_s",Sbtn);
480 zc_set_config(ctrl_sect,"btn_m",Mbtn);
481 zc_set_config(ctrl_sect,"btn_l",Lbtn);
482 zc_set_config(ctrl_sect,"btn_r",Rbtn);
483 zc_set_config(ctrl_sect,"btn_p",Pbtn);
484 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
485 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
486 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
487 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
488
489 zc_set_config(ctrl_sect,"btn_up",DUbtn);
490 zc_set_config(ctrl_sect,"btn_down",DDbtn);
491 zc_set_config(ctrl_sect,"btn_left",DLbtn);
492 zc_set_config(ctrl_sect,"btn_right",DRbtn);
493 }
494 }
495
496 void save_game_configs()
497 {
498 packfile_password("");
499
500 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
501
502 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
503 {
504 int o_window_x, o_window_y;
505 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
506 zc_set_config(cfg_sect,"window_x",o_window_x);
507 zc_set_config(cfg_sect,"window_y",o_window_y);
508 }
509
510 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
511 {
512 double monitor_scale = zc_get_monitor_scale();
513 window_width = al_get_display_width(all_get_display()) / monitor_scale;
514 window_height = al_get_display_height(all_get_display()) / monitor_scale;
515 zc_set_config(cfg_sect,"window_width",window_width);
516 zc_set_config(cfg_sect,"window_height",window_height);
517 }
518
519 zc_set_config(cfg_sect,"load_last",loadlast);
520 chop_path(qstdir);
521 zc_set_config(cfg_sect,qst_dir_name,qstdir);
522 zc_set_config("SAVEFILE","save_filename",save_file_name);
523 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
524 zc_set_config(cfg_sect,"frame_rest_suggest",frame_rest_suggest);
525
526 flush_config_file();
527 #ifdef __EMSCRIPTEN__
528 em_sync_fs();
529 #endif
530 }
531
532 //----------------------------------------------------------------
533
534 // Timers
535
536 17461 void fps_callback()
537 {
538 17461 lastfps=framecnt;
539 17461 dword tempsecs = fps_secs;
540 17461 ++tempsecs;
541 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
542 17461 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
543 17461 ++fps_secs;
544 17461 framecnt=0;
545 17461 }
546
547 END_OF_FUNCTION(fps_callback)
548
549 23 int32_t Z_init_timers()
550 {
551 static bool didit = false;
552 const static char *err_str = "Couldn't allocate timer";
553 23 err_str = err_str; //Unused variable warning
554
555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(didit)
556 return 1;
557
558 23 didit = true;
559
560 LOCK_VARIABLE(lastfps);
561 LOCK_VARIABLE(framecnt);
562 LOCK_FUNCTION(fps_callback);
563
564
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
565 return 0;
566
567 23 return 1;
568 23 }
569
570 void Z_remove_timers()
571 {
572 remove_int(fps_callback);
573 }
574
575 //----------------------------------------------------------------
576
577 void go()
578 {
579 scare_mouse();
580 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
581 unscare_mouse();
582 }
583
584 void comeback()
585 {
586 scare_mouse();
587 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
588 unscare_mouse();
589 }
590
591 void dump_pal(BITMAP *dest)
592 {
593 for(int32_t i=0; i<256; i++)
594 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
595 }
596
597 //----------------------------------------------------------------
598
599 //Handles converting the mouse sprite from the .dat file
600 23 void load_mouse()
601 {
602 23 system_pal();
603 23 scare_mouse();
604 23 set_mouse_sprite(NULL);
605
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 int32_t sz = vbound(int32_t(16*(is_large ? zc_get_config("zeldadx","cursor_scale_large",1.5) : zc_get_config("zeldadx","cursor_scale_small",1))),16,80);
606
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t j = 0; j < 4; ++j)
607 {
608 92 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
609 92 BITMAP* subbmp = create_bitmap_ex(8,16,16);
610
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(zcmouse[j])
611 destroy_bitmap(zcmouse[j]);
612 92 zcmouse[j] = create_bitmap_ex(8,sz,sz);
613 92 clear_bitmap(zcmouse[j]);
614 92 clear_bitmap(tmpbmp);
615 92 clear_bitmap(subbmp);
616 92 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
617
2/2
✓ Branch 0 taken 1472 times.
✓ Branch 1 taken 92 times.
1564 for(int32_t x = 0; x < 16; ++x)
618 {
619
2/2
✓ Branch 0 taken 23552 times.
✓ Branch 1 taken 1472 times.
25024 for(int32_t y = 0; y < 16; ++y)
620 {
621 23552 int32_t color = getpixel(tmpbmp, x, y);
622
5/5
✓ Branch 0 taken 21666 times.
✓ Branch 1 taken 437 times.
✓ Branch 2 taken 506 times.
✓ Branch 3 taken 529 times.
✓ Branch 4 taken 414 times.
23552 switch(color)
623 {
624 case dvc(1):
625 437 color = jwin_pal[jcCURSORMISC];
626 437 break;
627 case dvc(2):
628 506 color = jwin_pal[jcCURSOROUTLINE];
629 506 break;
630 case dvc(3):
631 529 color = jwin_pal[jcCURSORLIGHT];
632 529 break;
633 case dvc(5):
634 414 color = jwin_pal[jcCURSORDARK];
635 414 break;
636 }
637 23552 putpixel(subbmp, x, y, color);
638 23552 }
639 1472 }
640
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(sz!=16)
641 92 stretch_blit(subbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
642 else
643 blit(subbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
644 92 destroy_bitmap(tmpbmp);
645 92 destroy_bitmap(subbmp);
646 92 }
647 23 set_mouse_sprite(zcmouse[0]);
648
649 // Must attempt to show cursor for allegro 5 to render it with the associated palette.
650 23 set_palette(*hw_palette);
651 23 show_mouse(screen);
652 23 show_mouse(NULL);
653
654 23 unscare_mouse();
655 23 game_pal();
656 23 }
657
658 // sets the video mode and initializes the palette and mouse sprite
659 23 bool game_vid_mode(int32_t mode,int32_t wait)
660 {
661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
662 {
663 return false;
664 }
665
666 23 scrx = (resx-320)>>1;
667 23 scry = (resy-240)>>1;
668
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
669 92 zcmouse[q] = NULL;
670 23 load_mouse();
671 23 set_mouse_sprite(zcmouse[0]);
672
673
2/2
✓ Branch 0 taken 368 times.
✓ Branch 1 taken 23 times.
391 for(int32_t i=240; i<256; i++)
674 368 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
675
676 23 set_palette(RAMpal);
677 23 clear_to_color(screen,BLACK);
678
679 23 rest(wait);
680 23 return true;
681 23 }
682
683 4 void null_quest()
684 {
685 char qstdat_string[2048];
686 4 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
687 4 strcat(qstdat_string,"#NESQST_NEW_QST");
688
689 #ifdef __EMSCRIPTEN__
690 // The quest template data file is not included because it's really big and isn't really needed
691 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
692 // which is much smaller.
693 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
694 #endif
695
696 4 byte skip_flags[4] = { 0 };
697
698 4 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,true,true,true,skip_flags,0,false);
699 4 }
700
701 4 void init_NES_mode()
702 {
703 /*
704 // qst.dat may not load correctly without this...
705 QHeader.templatepath[0]='\0';
706
707 if(!init_colordata(true, &QHeader, &QMisc))
708 {
709 return;
710 }
711
712 loadfullpal();
713 init_tiles(false, &QHeader);
714 */
715 4 null_quest();
716 4 }
717
718 //----------------------------------------------------------------
719
720 qword trianglelines[16]=
721 {
722 0x0000000000000000ULL,
723 0xFD00000000000000ULL,
724 0xFDFD000000000000ULL,
725 0xFDFDFD0000000000ULL,
726 0xFDFDFDFD00000000ULL,
727 0xFDFDFDFDFD000000ULL,
728 0xFDFDFDFDFDFD0000ULL,
729 0xFDFDFDFDFDFDFD00ULL,
730 0xFDFDFDFDFDFDFDFDULL,
731 0x00FDFDFDFDFDFDFDULL,
732 0x0000FDFDFDFDFDFDULL,
733 0x000000FDFDFDFDFDULL,
734 0x00000000FDFDFDFDULL,
735 0x0000000000FDFDFDULL,
736 0x000000000000FDFDULL,
737 0x00000000000000FDULL,
738 };
739
740 word screen_triangles[28][32];
741 /*
742 qword triangles[4][16]= //[direction][value]
743 {
744 {
745 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
746 },
747 {
748 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
749 },
750 {
751 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
752 },
753 {
754 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
755 }
756 };
757 */
758
759
760 /*
761 byte triangles[4][16][8]= //[direction][value][line]
762 {
763 {
764 {
765 0, 0, 0, 0, 0, 0, 0, 0
766 },
767 {
768 1, 0, 0, 0, 0, 0, 0, 0
769 },
770 {
771 2, 1, 0, 0, 0, 0, 0, 0
772 },
773 {
774 3, 2, 1, 0, 0, 0, 0, 0
775 },
776 {
777 4, 3, 2, 1, 0, 0, 0, 0
778 },
779 {
780 5, 4, 3, 2, 1, 0, 0, 0
781 },
782 {
783 6, 5, 4, 3, 2, 1, 0, 0
784 },
785 {
786 7, 6, 5, 4, 3, 2, 1, 0
787 },
788 {
789 8, 7, 6, 5, 4, 3, 2, 1
790 },
791 {
792 8, 8, 7, 6, 5, 4, 3, 2
793 },
794 {
795 8, 8, 8, 7, 6, 5, 4, 3
796 },
797 {
798 8, 8, 8, 8, 7, 6, 5, 4
799 },
800 {
801 8, 8, 8, 8, 8, 7, 6, 5
802 },
803 {
804 8, 8, 8, 8, 8, 8, 7, 6
805 },
806 {
807 8, 8, 8, 8, 8, 8, 8, 7
808 },
809 {
810 8, 8, 8, 8, 8, 8, 8, 8
811 }
812 },
813 {
814 {
815 0, 0, 0, 0, 0, 0, 0, 0
816 },
817 {
818 15, 0, 0, 0, 0, 0, 0, 0
819 },
820 {
821 14, 15, 0, 0, 0, 0, 0, 0
822 },
823 {
824 13, 14, 15, 0, 0, 0, 0, 0
825 },
826 {
827 12, 13, 14, 15, 0, 0, 0, 0
828 },
829 {
830 11, 12, 13, 14, 15, 0, 0, 0
831 },
832 {
833 10, 11, 12, 13, 14, 15, 0, 0
834 },
835 {
836 9, 10, 11, 12, 13, 14, 15, 0
837 },
838 {
839 8, 9, 10, 11, 12, 13, 14, 15
840 },
841 {
842 8, 8, 9, 10, 11, 12, 13, 14
843 },
844 {
845 8, 8, 8, 9, 10, 11, 12, 13
846 },
847 {
848 8, 8, 8, 8, 9, 10, 11, 12
849 },
850 {
851 8, 8, 8, 8, 8, 9, 10, 11
852 },
853 {
854 8, 8, 8, 8, 8, 8, 9, 10
855 },
856 {
857 8, 8, 8, 8, 8, 8, 8, 9
858 },
859 {
860 8, 8, 8, 8, 8, 8, 8, 8
861 }
862 },
863 {
864 {
865 0, 0, 0, 0, 0, 0, 0, 0
866 },
867 {
868 0, 0, 0, 0, 0, 0, 0, 1
869 },
870 {
871 0, 0, 0, 0, 0, 0, 1, 2
872 },
873 {
874 0, 0, 0, 0, 0, 1, 2, 3
875 },
876 {
877 0, 0, 0, 0, 1, 2, 3, 4
878 },
879 {
880 0, 0, 0, 1, 2, 3, 4, 5
881 },
882 {
883 0, 0, 1, 2, 3, 4, 5, 6
884 },
885 {
886 0, 1, 2, 3, 4, 5, 6, 7
887 },
888 {
889 1, 2, 3, 4, 5, 6, 7, 8
890 },
891 {
892 2, 3, 4, 5, 6, 7, 8, 8
893 },
894 {
895 3, 4, 5, 6, 7, 8, 8, 8
896 },
897 {
898 4, 5, 6, 7, 8, 8, 8, 8
899 },
900 {
901 5, 6, 7, 8, 8, 8, 8, 8
902 },
903 {
904 6, 7, 8, 8, 8, 8, 8, 8
905 },
906 {
907 7, 8, 8, 8, 8, 8, 8, 8
908 },
909 {
910 8, 8, 8, 8, 8, 8, 8, 8
911 }
912 },
913 {
914 {
915 0, 0, 0, 0, 0, 0, 0, 0
916 },
917 {
918 0, 0, 0, 0, 0, 0, 0, 15
919 },
920 {
921 0, 0, 0, 0, 0, 0, 15, 14
922 },
923 {
924 0, 0, 0, 0, 0, 15, 14, 13
925 },
926 {
927 0, 0, 0, 0, 15, 14, 13, 12
928 },
929 {
930 0, 0, 0, 15, 14, 13, 12, 11
931 },
932 {
933 0, 0, 15, 14, 13, 12, 11, 10
934 },
935 {
936 0, 15, 14, 13, 12, 11, 10, 9
937 },
938 {
939 15, 14, 13, 12, 11, 10, 9, 8
940 },
941 {
942 14, 13, 12, 11, 10, 9, 8, 8
943 },
944 {
945 13, 12, 11, 10, 9, 8, 8, 8
946 },
947 {
948 12, 11, 10, 9, 8, 8, 8, 8
949 },
950 {
951 11, 10, 9, 8, 8, 8, 8, 8
952 },
953 {
954 10, 9, 8, 8, 8, 8, 8, 8
955 },
956 {
957 9, 8, 8, 8, 8, 8, 8, 8
958 },
959 {
960 8, 8, 8, 8, 8, 8, 8, 8
961 }
962 }
963 };
964 */
965
966
967
968 /*
969 for (int32_t blockrow=0; blockrow<30; ++i)
970 {
971 for (int32_t linerow=0; linerow<8; ++i)
972 {
973 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
974 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
975 {
976 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
977 ++triangleline;
978 }
979 }
980 }
981 */
982
983 // the ULL suffixes are to prevent this warning:
984 // warning: integer constant is too large for "int32_t" type
985
986 qword triangles[4][16][8]= //[direction][value][line]
987 {
988 {
989 {
990 0x0000000000000000ULL,
991 0x0000000000000000ULL,
992 0x0000000000000000ULL,
993 0x0000000000000000ULL,
994 0x0000000000000000ULL,
995 0x0000000000000000ULL,
996 0x0000000000000000ULL,
997 0x0000000000000000ULL
998 },
999 {
1000 0xFD00000000000000ULL,
1001 0x0000000000000000ULL,
1002 0x0000000000000000ULL,
1003 0x0000000000000000ULL,
1004 0x0000000000000000ULL,
1005 0x0000000000000000ULL,
1006 0x0000000000000000ULL,
1007 0x0000000000000000ULL
1008 },
1009 {
1010 0xFDFD000000000000ULL,
1011 0xFD00000000000000ULL,
1012 0x0000000000000000ULL,
1013 0x0000000000000000ULL,
1014 0x0000000000000000ULL,
1015 0x0000000000000000ULL,
1016 0x0000000000000000ULL,
1017 0x0000000000000000ULL
1018 },
1019 {
1020 0xFDFDFD0000000000ULL,
1021 0xFDFD000000000000ULL,
1022 0xFD00000000000000ULL,
1023 0x0000000000000000ULL,
1024 0x0000000000000000ULL,
1025 0x0000000000000000ULL,
1026 0x0000000000000000ULL,
1027 0x0000000000000000ULL
1028 },
1029 {
1030 0xFDFDFDFD00000000ULL,
1031 0xFDFDFD0000000000ULL,
1032 0xFDFD000000000000ULL,
1033 0xFD00000000000000ULL,
1034 0x0000000000000000ULL,
1035 0x0000000000000000ULL,
1036 0x0000000000000000ULL,
1037 0x0000000000000000ULL
1038 },
1039 {
1040 0xFDFDFDFDFD000000ULL,
1041 0xFDFDFDFD00000000ULL,
1042 0xFDFDFD0000000000ULL,
1043 0xFDFD000000000000ULL,
1044 0xFD00000000000000ULL,
1045 0x0000000000000000ULL,
1046 0x0000000000000000ULL,
1047 0x0000000000000000ULL
1048 },
1049 {
1050 0xFDFDFDFDFDFD0000ULL,
1051 0xFDFDFDFDFD000000ULL,
1052 0xFDFDFDFD00000000ULL,
1053 0xFDFDFD0000000000ULL,
1054 0xFDFD000000000000ULL,
1055 0xFD00000000000000ULL,
1056 0x0000000000000000ULL,
1057 0x0000000000000000ULL
1058 },
1059 {
1060 0xFDFDFDFDFDFDFD00ULL,
1061 0xFDFDFDFDFDFD0000ULL,
1062 0xFDFDFDFDFD000000ULL,
1063 0xFDFDFDFD00000000ULL,
1064 0xFDFDFD0000000000ULL,
1065 0xFDFD000000000000ULL,
1066 0xFD00000000000000ULL,
1067 0x0000000000000000ULL
1068 },
1069 {
1070 0xFDFDFDFDFDFDFDFDULL,
1071 0xFDFDFDFDFDFDFD00ULL,
1072 0xFDFDFDFDFDFD0000ULL,
1073 0xFDFDFDFDFD000000ULL,
1074 0xFDFDFDFD00000000ULL,
1075 0xFDFDFD0000000000ULL,
1076 0xFDFD000000000000ULL,
1077 0xFD00000000000000ULL
1078 },
1079 {
1080 0xFDFDFDFDFDFDFDFDULL,
1081 0xFDFDFDFDFDFDFDFDULL,
1082 0xFDFDFDFDFDFDFD00ULL,
1083 0xFDFDFDFDFDFD0000ULL,
1084 0xFDFDFDFDFD000000ULL,
1085 0xFDFDFDFD00000000ULL,
1086 0xFDFDFD0000000000ULL,
1087 0xFDFD000000000000ULL
1088 },
1089 {
1090 0xFDFDFDFDFDFDFDFDULL,
1091 0xFDFDFDFDFDFDFDFDULL,
1092 0xFDFDFDFDFDFDFDFDULL,
1093 0xFDFDFDFDFDFDFD00ULL,
1094 0xFDFDFDFDFDFD0000ULL,
1095 0xFDFDFDFDFD000000ULL,
1096 0xFDFDFDFD00000000ULL,
1097 0xFDFDFD0000000000ULL
1098 },
1099 {
1100 0xFDFDFDFDFDFDFDFDULL,
1101 0xFDFDFDFDFDFDFDFDULL,
1102 0xFDFDFDFDFDFDFDFDULL,
1103 0xFDFDFDFDFDFDFDFDULL,
1104 0xFDFDFDFDFDFDFD00ULL,
1105 0xFDFDFDFDFDFD0000ULL,
1106 0xFDFDFDFDFD000000ULL,
1107 0xFDFDFDFD00000000ULL
1108 },
1109 {
1110 0xFDFDFDFDFDFDFDFDULL,
1111 0xFDFDFDFDFDFDFDFDULL,
1112 0xFDFDFDFDFDFDFDFDULL,
1113 0xFDFDFDFDFDFDFDFDULL,
1114 0xFDFDFDFDFDFDFDFDULL,
1115 0xFDFDFDFDFDFDFD00ULL,
1116 0xFDFDFDFDFDFD0000ULL,
1117 0xFDFDFDFDFD000000ULL
1118 },
1119 {
1120 0xFDFDFDFDFDFDFDFDULL,
1121 0xFDFDFDFDFDFDFDFDULL,
1122 0xFDFDFDFDFDFDFDFDULL,
1123 0xFDFDFDFDFDFDFDFDULL,
1124 0xFDFDFDFDFDFDFDFDULL,
1125 0xFDFDFDFDFDFDFDFDULL,
1126 0xFDFDFDFDFDFDFD00ULL,
1127 0xFDFDFDFDFDFD0000ULL
1128 },
1129 {
1130 0xFDFDFDFDFDFDFDFDULL,
1131 0xFDFDFDFDFDFDFDFDULL,
1132 0xFDFDFDFDFDFDFDFDULL,
1133 0xFDFDFDFDFDFDFDFDULL,
1134 0xFDFDFDFDFDFDFDFDULL,
1135 0xFDFDFDFDFDFDFDFDULL,
1136 0xFDFDFDFDFDFDFDFDULL,
1137 0xFDFDFDFDFDFDFD00ULL
1138 },
1139 {
1140 0xFDFDFDFDFDFDFDFDULL,
1141 0xFDFDFDFDFDFDFDFDULL,
1142 0xFDFDFDFDFDFDFDFDULL,
1143 0xFDFDFDFDFDFDFDFDULL,
1144 0xFDFDFDFDFDFDFDFDULL,
1145 0xFDFDFDFDFDFDFDFDULL,
1146 0xFDFDFDFDFDFDFDFDULL,
1147 0xFDFDFDFDFDFDFDFDULL
1148 }
1149 },
1150 {
1151 {
1152 0x0000000000000000ULL,
1153 0x0000000000000000ULL,
1154 0x0000000000000000ULL,
1155 0x0000000000000000ULL,
1156 0x0000000000000000ULL,
1157 0x0000000000000000ULL,
1158 0x0000000000000000ULL,
1159 0x0000000000000000ULL
1160 },
1161 {
1162 0x00000000000000FDULL,
1163 0x0000000000000000ULL,
1164 0x0000000000000000ULL,
1165 0x0000000000000000ULL,
1166 0x0000000000000000ULL,
1167 0x0000000000000000ULL,
1168 0x0000000000000000ULL,
1169 0x0000000000000000ULL
1170 },
1171 {
1172 0x000000000000FDFDULL,
1173 0x00000000000000FDULL,
1174 0x0000000000000000ULL,
1175 0x0000000000000000ULL,
1176 0x0000000000000000ULL,
1177 0x0000000000000000ULL,
1178 0x0000000000000000ULL,
1179 0x0000000000000000ULL
1180 },
1181 {
1182 0x0000000000FDFDFDULL,
1183 0x000000000000FDFDULL,
1184 0x00000000000000FDULL,
1185 0x0000000000000000ULL,
1186 0x0000000000000000ULL,
1187 0x0000000000000000ULL,
1188 0x0000000000000000ULL,
1189 0x0000000000000000ULL
1190 },
1191 {
1192 0x00000000FDFDFDFDULL,
1193 0x0000000000FDFDFDULL,
1194 0x000000000000FDFDULL,
1195 0x00000000000000FDULL,
1196 0x0000000000000000ULL,
1197 0x0000000000000000ULL,
1198 0x0000000000000000ULL,
1199 0x0000000000000000ULL
1200 },
1201 {
1202 0x000000FDFDFDFDFDULL,
1203 0x00000000FDFDFDFDULL,
1204 0x0000000000FDFDFDULL,
1205 0x000000000000FDFDULL,
1206 0x00000000000000FDULL,
1207 0x0000000000000000ULL,
1208 0x0000000000000000ULL,
1209 0x0000000000000000ULL
1210 },
1211 {
1212 0x0000FDFDFDFDFDFDULL,
1213 0x000000FDFDFDFDFDULL,
1214 0x00000000FDFDFDFDULL,
1215 0x0000000000FDFDFDULL,
1216 0x000000000000FDFDULL,
1217 0x00000000000000FDULL,
1218 0x0000000000000000ULL,
1219 0x0000000000000000ULL
1220 },
1221 {
1222 0x00FDFDFDFDFDFDFDULL,
1223 0x0000FDFDFDFDFDFDULL,
1224 0x000000FDFDFDFDFDULL,
1225 0x00000000FDFDFDFDULL,
1226 0x0000000000FDFDFDULL,
1227 0x000000000000FDFDULL,
1228 0x00000000000000FDULL,
1229 0x0000000000000000ULL
1230 },
1231 {
1232 0xFDFDFDFDFDFDFDFDULL,
1233 0x00FDFDFDFDFDFDFDULL,
1234 0x0000FDFDFDFDFDFDULL,
1235 0x000000FDFDFDFDFDULL,
1236 0x00000000FDFDFDFDULL,
1237 0x0000000000FDFDFDULL,
1238 0x000000000000FDFDULL,
1239 0x00000000000000FDULL
1240 },
1241 {
1242 0xFDFDFDFDFDFDFDFDULL,
1243 0xFDFDFDFDFDFDFDFDULL,
1244 0x00FDFDFDFDFDFDFDULL,
1245 0x0000FDFDFDFDFDFDULL,
1246 0x000000FDFDFDFDFDULL,
1247 0x00000000FDFDFDFDULL,
1248 0x0000000000FDFDFDULL,
1249 0x000000000000FDFDULL
1250 },
1251 {
1252 0xFDFDFDFDFDFDFDFDULL,
1253 0xFDFDFDFDFDFDFDFDULL,
1254 0xFDFDFDFDFDFDFDFDULL,
1255 0x00FDFDFDFDFDFDFDULL,
1256 0x0000FDFDFDFDFDFDULL,
1257 0x000000FDFDFDFDFDULL,
1258 0x00000000FDFDFDFDULL,
1259 0x0000000000FDFDFDULL
1260 },
1261 {
1262 0xFDFDFDFDFDFDFDFDULL,
1263 0xFDFDFDFDFDFDFDFDULL,
1264 0xFDFDFDFDFDFDFDFDULL,
1265 0xFDFDFDFDFDFDFDFDULL,
1266 0x00FDFDFDFDFDFDFDULL,
1267 0x0000FDFDFDFDFDFDULL,
1268 0x000000FDFDFDFDFDULL,
1269 0x00000000FDFDFDFDULL
1270 },
1271 {
1272 0xFDFDFDFDFDFDFDFDULL,
1273 0xFDFDFDFDFDFDFDFDULL,
1274 0xFDFDFDFDFDFDFDFDULL,
1275 0xFDFDFDFDFDFDFDFDULL,
1276 0xFDFDFDFDFDFDFDFDULL,
1277 0x00FDFDFDFDFDFDFDULL,
1278 0x0000FDFDFDFDFDFDULL,
1279 0x000000FDFDFDFDFDULL
1280 },
1281 {
1282 0xFDFDFDFDFDFDFDFDULL,
1283 0xFDFDFDFDFDFDFDFDULL,
1284 0xFDFDFDFDFDFDFDFDULL,
1285 0xFDFDFDFDFDFDFDFDULL,
1286 0xFDFDFDFDFDFDFDFDULL,
1287 0xFDFDFDFDFDFDFDFDULL,
1288 0x00FDFDFDFDFDFDFDULL,
1289 0x0000FDFDFDFDFDFDULL
1290 },
1291 {
1292 0xFDFDFDFDFDFDFDFDULL,
1293 0xFDFDFDFDFDFDFDFDULL,
1294 0xFDFDFDFDFDFDFDFDULL,
1295 0xFDFDFDFDFDFDFDFDULL,
1296 0xFDFDFDFDFDFDFDFDULL,
1297 0xFDFDFDFDFDFDFDFDULL,
1298 0xFDFDFDFDFDFDFDFDULL,
1299 0x00FDFDFDFDFDFDFDULL
1300 },
1301 {
1302 0xFDFDFDFDFDFDFDFDULL,
1303 0xFDFDFDFDFDFDFDFDULL,
1304 0xFDFDFDFDFDFDFDFDULL,
1305 0xFDFDFDFDFDFDFDFDULL,
1306 0xFDFDFDFDFDFDFDFDULL,
1307 0xFDFDFDFDFDFDFDFDULL,
1308 0xFDFDFDFDFDFDFDFDULL,
1309 0xFDFDFDFDFDFDFDFDULL
1310 }
1311 },
1312 {
1313 {
1314 0x0000000000000000ULL,
1315 0x0000000000000000ULL,
1316 0x0000000000000000ULL,
1317 0x0000000000000000ULL,
1318 0x0000000000000000ULL,
1319 0x0000000000000000ULL,
1320 0x0000000000000000ULL,
1321 0x0000000000000000ULL
1322 },
1323 {
1324 0x0000000000000000ULL,
1325 0x0000000000000000ULL,
1326 0x0000000000000000ULL,
1327 0x0000000000000000ULL,
1328 0x0000000000000000ULL,
1329 0x0000000000000000ULL,
1330 0x0000000000000000ULL,
1331 0xFD00000000000000ULL
1332 },
1333 {
1334 0x0000000000000000ULL,
1335 0x0000000000000000ULL,
1336 0x0000000000000000ULL,
1337 0x0000000000000000ULL,
1338 0x0000000000000000ULL,
1339 0x0000000000000000ULL,
1340 0xFD00000000000000ULL,
1341 0xFDFD000000000000ULL
1342 },
1343 {
1344 0x0000000000000000ULL,
1345 0x0000000000000000ULL,
1346 0x0000000000000000ULL,
1347 0x0000000000000000ULL,
1348 0x0000000000000000ULL,
1349 0xFD00000000000000ULL,
1350 0xFDFD000000000000ULL,
1351 0xFDFDFD0000000000ULL
1352 },
1353 {
1354 0x0000000000000000ULL,
1355 0x0000000000000000ULL,
1356 0x0000000000000000ULL,
1357 0x0000000000000000ULL,
1358 0xFD00000000000000ULL,
1359 0xFDFD000000000000ULL,
1360 0xFDFDFD0000000000ULL,
1361 0xFDFDFDFD00000000ULL
1362 },
1363 {
1364 0x0000000000000000ULL,
1365 0x0000000000000000ULL,
1366 0x0000000000000000ULL,
1367 0xFD00000000000000ULL,
1368 0xFDFD000000000000ULL,
1369 0xFDFDFD0000000000ULL,
1370 0xFDFDFDFD00000000ULL,
1371 0xFDFDFDFDFD000000ULL
1372 },
1373 {
1374 0x0000000000000000ULL,
1375 0x0000000000000000ULL,
1376 0xFD00000000000000ULL,
1377 0xFDFD000000000000ULL,
1378 0xFDFDFD0000000000ULL,
1379 0xFDFDFDFD00000000ULL,
1380 0xFDFDFDFDFD000000ULL,
1381 0xFDFDFDFDFDFD0000ULL
1382 },
1383 {
1384 0x0000000000000000ULL,
1385 0xFD00000000000000ULL,
1386 0xFDFD000000000000ULL,
1387 0xFDFDFD0000000000ULL,
1388 0xFDFDFDFD00000000ULL,
1389 0xFDFDFDFDFD000000ULL,
1390 0xFDFDFDFDFDFD0000ULL,
1391 0xFDFDFDFDFDFDFD00ULL
1392 },
1393 {
1394 0xFD00000000000000ULL,
1395 0xFDFD000000000000ULL,
1396 0xFDFDFD0000000000ULL,
1397 0xFDFDFDFD00000000ULL,
1398 0xFDFDFDFDFD000000ULL,
1399 0xFDFDFDFDFDFD0000ULL,
1400 0xFDFDFDFDFDFDFD00ULL,
1401 0xFDFDFDFDFDFDFDFDULL
1402 },
1403 {
1404 0xFDFD000000000000ULL,
1405 0xFDFDFD0000000000ULL,
1406 0xFDFDFDFD00000000ULL,
1407 0xFDFDFDFDFD000000ULL,
1408 0xFDFDFDFDFDFD0000ULL,
1409 0xFDFDFDFDFDFDFD00ULL,
1410 0xFDFDFDFDFDFDFDFDULL,
1411 0xFDFDFDFDFDFDFDFDULL
1412 },
1413 {
1414 0xFDFDFD0000000000ULL,
1415 0xFDFDFDFD00000000ULL,
1416 0xFDFDFDFDFD000000ULL,
1417 0xFDFDFDFDFDFD0000ULL,
1418 0xFDFDFDFDFDFDFD00ULL,
1419 0xFDFDFDFDFDFDFDFDULL,
1420 0xFDFDFDFDFDFDFDFDULL,
1421 0xFDFDFDFDFDFDFDFDULL
1422 },
1423 {
1424 0xFDFDFDFD00000000ULL,
1425 0xFDFDFDFDFD000000ULL,
1426 0xFDFDFDFDFDFD0000ULL,
1427 0xFDFDFDFDFDFDFD00ULL,
1428 0xFDFDFDFDFDFDFDFDULL,
1429 0xFDFDFDFDFDFDFDFDULL,
1430 0xFDFDFDFDFDFDFDFDULL,
1431 0xFDFDFDFDFDFDFDFDULL
1432 },
1433 {
1434 0xFDFDFDFDFD000000ULL,
1435 0xFDFDFDFDFDFD0000ULL,
1436 0xFDFDFDFDFDFDFD00ULL,
1437 0xFDFDFDFDFDFDFDFDULL,
1438 0xFDFDFDFDFDFDFDFDULL,
1439 0xFDFDFDFDFDFDFDFDULL,
1440 0xFDFDFDFDFDFDFDFDULL,
1441 0xFDFDFDFDFDFDFDFDULL
1442 },
1443 {
1444 0xFDFDFDFDFDFD0000ULL,
1445 0xFDFDFDFDFDFDFD00ULL,
1446 0xFDFDFDFDFDFDFDFDULL,
1447 0xFDFDFDFDFDFDFDFDULL,
1448 0xFDFDFDFDFDFDFDFDULL,
1449 0xFDFDFDFDFDFDFDFDULL,
1450 0xFDFDFDFDFDFDFDFDULL,
1451 0xFDFDFDFDFDFDFDFDULL
1452 },
1453 {
1454 0xFDFDFDFDFDFDFD00ULL,
1455 0xFDFDFDFDFDFDFDFDULL,
1456 0xFDFDFDFDFDFDFDFDULL,
1457 0xFDFDFDFDFDFDFDFDULL,
1458 0xFDFDFDFDFDFDFDFDULL,
1459 0xFDFDFDFDFDFDFDFDULL,
1460 0xFDFDFDFDFDFDFDFDULL,
1461 0xFDFDFDFDFDFDFDFDULL
1462 },
1463 {
1464 0xFDFDFDFDFDFDFDFDULL,
1465 0xFDFDFDFDFDFDFDFDULL,
1466 0xFDFDFDFDFDFDFDFDULL,
1467 0xFDFDFDFDFDFDFDFDULL,
1468 0xFDFDFDFDFDFDFDFDULL,
1469 0xFDFDFDFDFDFDFDFDULL,
1470 0xFDFDFDFDFDFDFDFDULL,
1471 0xFDFDFDFDFDFDFDFDULL
1472 }
1473 },
1474 {
1475 {
1476 0x0000000000000000ULL,
1477 0x0000000000000000ULL,
1478 0x0000000000000000ULL,
1479 0x0000000000000000ULL,
1480 0x0000000000000000ULL,
1481 0x0000000000000000ULL,
1482 0x0000000000000000ULL,
1483 0x0000000000000000ULL
1484 },
1485 {
1486 0x0000000000000000ULL,
1487 0x0000000000000000ULL,
1488 0x0000000000000000ULL,
1489 0x0000000000000000ULL,
1490 0x0000000000000000ULL,
1491 0x0000000000000000ULL,
1492 0x0000000000000000ULL,
1493 0x00000000000000FDULL
1494 },
1495 {
1496 0x0000000000000000ULL,
1497 0x0000000000000000ULL,
1498 0x0000000000000000ULL,
1499 0x0000000000000000ULL,
1500 0x0000000000000000ULL,
1501 0x0000000000000000ULL,
1502 0x00000000000000FDULL,
1503 0x000000000000FDFDULL
1504 },
1505 {
1506 0x0000000000000000ULL,
1507 0x0000000000000000ULL,
1508 0x0000000000000000ULL,
1509 0x0000000000000000ULL,
1510 0x0000000000000000ULL,
1511 0x00000000000000FDULL,
1512 0x000000000000FDFDULL,
1513 0x0000000000FDFDFDULL
1514 },
1515 {
1516 0x0000000000000000ULL,
1517 0x0000000000000000ULL,
1518 0x0000000000000000ULL,
1519 0x0000000000000000ULL,
1520 0x00000000000000FDULL,
1521 0x000000000000FDFDULL,
1522 0x0000000000FDFDFDULL,
1523 0x00000000FDFDFDFDULL
1524 },
1525 {
1526 0x0000000000000000ULL,
1527 0x0000000000000000ULL,
1528 0x0000000000000000ULL,
1529 0x00000000000000FDULL,
1530 0x000000000000FDFDULL,
1531 0x0000000000FDFDFDULL,
1532 0x00000000FDFDFDFDULL,
1533 0x000000FDFDFDFDFDULL
1534 },
1535 {
1536 0x0000000000000000ULL,
1537 0x0000000000000000ULL,
1538 0x00000000000000FDULL,
1539 0x000000000000FDFDULL,
1540 0x0000000000FDFDFDULL,
1541 0x00000000FDFDFDFDULL,
1542 0x000000FDFDFDFDFDULL,
1543 0x0000FDFDFDFDFDFDULL
1544 },
1545 {
1546 0x0000000000000000ULL,
1547 0x00000000000000FDULL,
1548 0x000000000000FDFDULL,
1549 0x0000000000FDFDFDULL,
1550 0x00000000FDFDFDFDULL,
1551 0x000000FDFDFDFDFDULL,
1552 0x0000FDFDFDFDFDFDULL,
1553 0x00FDFDFDFDFDFDFDULL
1554 },
1555 {
1556 0x00000000000000FDULL,
1557 0x000000000000FDFDULL,
1558 0x0000000000FDFDFDULL,
1559 0x00000000FDFDFDFDULL,
1560 0x000000FDFDFDFDFDULL,
1561 0x0000FDFDFDFDFDFDULL,
1562 0x00FDFDFDFDFDFDFDULL,
1563 0xFDFDFDFDFDFDFDFDULL
1564 },
1565 {
1566 0x000000000000FDFDULL,
1567 0x0000000000FDFDFDULL,
1568 0x00000000FDFDFDFDULL,
1569 0x000000FDFDFDFDFDULL,
1570 0x0000FDFDFDFDFDFDULL,
1571 0x00FDFDFDFDFDFDFDULL,
1572 0xFDFDFDFDFDFDFDFDULL,
1573 0xFDFDFDFDFDFDFDFDULL
1574 },
1575 {
1576 0x0000000000FDFDFDULL,
1577 0x00000000FDFDFDFDULL,
1578 0x000000FDFDFDFDFDULL,
1579 0x0000FDFDFDFDFDFDULL,
1580 0x00FDFDFDFDFDFDFDULL,
1581 0xFDFDFDFDFDFDFDFDULL,
1582 0xFDFDFDFDFDFDFDFDULL,
1583 0xFDFDFDFDFDFDFDFDULL
1584 },
1585 {
1586 0x00000000FDFDFDFDULL,
1587 0x000000FDFDFDFDFDULL,
1588 0x0000FDFDFDFDFDFDULL,
1589 0x00FDFDFDFDFDFDFDULL,
1590 0xFDFDFDFDFDFDFDFDULL,
1591 0xFDFDFDFDFDFDFDFDULL,
1592 0xFDFDFDFDFDFDFDFDULL,
1593 0xFDFDFDFDFDFDFDFDULL
1594 },
1595 {
1596 0x000000FDFDFDFDFDULL,
1597 0x0000FDFDFDFDFDFDULL,
1598 0x00FDFDFDFDFDFDFDULL,
1599 0xFDFDFDFDFDFDFDFDULL,
1600 0xFDFDFDFDFDFDFDFDULL,
1601 0xFDFDFDFDFDFDFDFDULL,
1602 0xFDFDFDFDFDFDFDFDULL,
1603 0xFDFDFDFDFDFDFDFDULL
1604 },
1605 {
1606 0x0000FDFDFDFDFDFDULL,
1607 0x00FDFDFDFDFDFDFDULL,
1608 0xFDFDFDFDFDFDFDFDULL,
1609 0xFDFDFDFDFDFDFDFDULL,
1610 0xFDFDFDFDFDFDFDFDULL,
1611 0xFDFDFDFDFDFDFDFDULL,
1612 0xFDFDFDFDFDFDFDFDULL,
1613 0xFDFDFDFDFDFDFDFDULL
1614 },
1615 {
1616 0x00FDFDFDFDFDFDFDULL,
1617 0xFDFDFDFDFDFDFDFDULL,
1618 0xFDFDFDFDFDFDFDFDULL,
1619 0xFDFDFDFDFDFDFDFDULL,
1620 0xFDFDFDFDFDFDFDFDULL,
1621 0xFDFDFDFDFDFDFDFDULL,
1622 0xFDFDFDFDFDFDFDFDULL,
1623 0xFDFDFDFDFDFDFDFDULL
1624 },
1625 {
1626 0xFDFDFDFDFDFDFDFDULL,
1627 0xFDFDFDFDFDFDFDFDULL,
1628 0xFDFDFDFDFDFDFDFDULL,
1629 0xFDFDFDFDFDFDFDFDULL,
1630 0xFDFDFDFDFDFDFDFDULL,
1631 0xFDFDFDFDFDFDFDFDULL,
1632 0xFDFDFDFDFDFDFDFDULL,
1633 0xFDFDFDFDFDFDFDFDULL
1634 }
1635 }
1636 };
1637
1638 int32_t black_opening_count=0;
1639 int32_t black_opening_x,black_opening_y;
1640 int32_t black_opening_shape;
1641
1642 459 int32_t choose_opening_shape()
1643 {
1644 // First, count how many bits are set
1645 459 int32_t numBits=0;
1646 int32_t bitCounter;
1647
1648
2/2
✓ Branch 0 taken 2295 times.
✓ Branch 1 taken 459 times.
2754 for(int32_t i=0; i<bosMAX; i++)
1649 {
1650
2/2
✓ Branch 0 taken 1620 times.
✓ Branch 1 taken 675 times.
2295 if(COOLSCROLL&(1<<i))
1651 675 numBits++;
1652 2295 }
1653
1654 // Shouldn't happen...
1655
1/2
✓ Branch 0 taken 459 times.
✗ Branch 1 not taken.
459 if(numBits==0)
1656 return bosCIRCLE;
1657
1658 // Pick a bit
1659 459 bitCounter=zc_rand()%numBits+1;
1660
1661
2/2
✓ Branch 0 taken 671 times.
✓ Branch 1 taken 26 times.
697 for(int32_t i=0; i<bosMAX; i++)
1662 {
1663 // If this bit is set, decrement the bit counter
1664
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 589 times.
671 if(COOLSCROLL&(1<<i))
1665 589 bitCounter--;
1666
1667 // When the counter hits 0, return a value based on
1668 // which bit it stopped on.
1669 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1670
2/2
✓ Branch 0 taken 433 times.
✓ Branch 1 taken 238 times.
671 if(bitCounter==0)
1671 433 return i;
1672 238 }
1673
1674 // Shouldn't be necessary, but the compiler might complain, at least
1675 26 return bosCIRCLE;
1676 459 }
1677
1678 140 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1679 {
1680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1681
1682 140 int32_t w=256, h=224;
1683 140 int32_t blockrows=28, blockcolumns=32;
1684 140 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1685
1686
2/2
✓ Branch 0 taken 3920 times.
✓ Branch 1 taken 140 times.
4060 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1687 {
1688
2/2
✓ Branch 0 taken 125440 times.
✓ Branch 1 taken 3920 times.
129360 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1689 {
1690
2/2
✓ Branch 0 taken 67190 times.
✓ Branch 1 taken 58250 times.
125440 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1691 125440 }
1692 3920 }
1693
1694 140 black_opening_count = 66;
1695 140 black_opening_x = x;
1696 140 black_opening_y = y;
1697 140 lensclk = 0;
1698 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1699
1700
1701
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(black_opening_shape == bosFADEBLACK)
1702 {
1703 refreshTints();
1704 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1705 }
1706
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(wait)
1707 {
1708 FFCore.warpScriptCheck();
1709 for(int32_t i=0; i<66; i++)
1710 {
1711 draw_screen(tmpscr);
1712 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1713 syskeys();
1714 advanceframe(true);
1715
1716 if(Quit)
1717 {
1718 break;
1719 }
1720 }
1721 }
1722 140 }
1723
1724 319 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1725 {
1726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 319 times.
319 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1727
1728 319 int32_t w=256, h=224;
1729 319 int32_t blockrows=28, blockcolumns=32;
1730 319 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1731
1732
2/2
✓ Branch 0 taken 8932 times.
✓ Branch 1 taken 319 times.
9251 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1733 {
1734
2/2
✓ Branch 0 taken 285824 times.
✓ Branch 1 taken 8932 times.
294756 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1735 {
1736
2/2
✓ Branch 0 taken 137279 times.
✓ Branch 1 taken 148545 times.
285824 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1737 285824 }
1738 8932 }
1739
1740 319 black_opening_count = -66;
1741 319 black_opening_x = x;
1742 319 black_opening_y = y;
1743 319 lensclk = 0;
1744
1/2
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
319 if(black_opening_shape == bosFADEBLACK)
1745 {
1746 refreshTints();
1747 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1748 }
1749
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 209 times.
319 if(wait)
1750 {
1751 209 FFCore.warpScriptCheck();
1752
2/2
✓ Branch 0 taken 209 times.
✓ Branch 1 taken 13794 times.
14003 for(int32_t i=0; i<66; i++)
1753 {
1754 13794 draw_screen(tmpscr);
1755 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1756 13794 syskeys();
1757 13794 advanceframe(true);
1758
1759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13794 times.
13794 if(Quit)
1760 {
1761 break;
1762 }
1763 13794 }
1764 209 }
1765 319 }
1766
1767 30294 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1768 {
1769 30294 clear_to_color(tmp_scr,BLACK);
1770 30294 int32_t w=256, h=224;
1771
1772
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 1650 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27126 times.
30294 switch(black_opening_shape)
1773 {
1774 case bosOVAL:
1775 {
1776 858 double new_w=(w/2)+abs(w/2-x);
1777 858 double new_h=(h/2)+abs(h/2-y);
1778 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1779 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1780 858 break;
1781 }
1782
1783 case bosTRIANGLE:
1784 {
1785 660 double new_w=(w/2)+abs(w/2-x);
1786 660 double new_h=(h/2)+abs(h/2-y);
1787 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1788 660 double P2= (PI/2);
1789 660 double P23=(2*PI/3);
1790 660 double P43=(4*PI/3);
1791 660 double Pa= (-4*PI*a/(3*max_a));
1792 660 double angle=P2+Pa;
1793 660 double a0=angle;
1794 660 double a2=angle+P23;
1795 660 double a4=angle+P43;
1796 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1797 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1798 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1799 0);
1800 660 break;
1801 }
1802
1803 case bosSMAS:
1804 {
1805
2/2
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 990 times.
1650 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1806
1807
2/2
✓ Branch 0 taken 46200 times.
✓ Branch 1 taken 1650 times.
47850 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1808 {
1809
2/2
✓ Branch 0 taken 369600 times.
✓ Branch 1 taken 46200 times.
415800 for(int32_t linerow=0; linerow<8; ++linerow)
1810 {
1811 369600 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1812
1813
2/2
✓ Branch 0 taken 11827200 times.
✓ Branch 1 taken 369600 times.
12196800 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1814 {
1815 35481600 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1816
6/6
✓ Branch 0 taken 8249728 times.
✓ Branch 1 taken 3577472 times.
✓ Branch 2 taken 7829672 times.
✓ Branch 3 taken 3997528 times.
✓ Branch 4 taken 4252200 times.
✓ Branch 5 taken 3577472 times.
11827200 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1817 11827200 [linerow];
1818 11827200 ++triangleline;
1819
1820
2/2
✓ Branch 0 taken 10348800 times.
✓ Branch 1 taken 1478400 times.
11827200 if(linerow==0)
1821 {
1822 1478400 }
1823 11827200 }
1824 369600 }
1825 46200 }
1826
1827 1650 break;
1828 }
1829
1830 case bosFADEBLACK:
1831 {
1832 if(black_opening_count<0)
1833 {
1834 black_fade(zc_min(-black_opening_count,63));
1835 }
1836 else if(black_opening_count>0)
1837 {
1838 black_fade(63-zc_max(black_opening_count-3,0));
1839 }
1840 else black_fade(0);
1841 return; //no blitting from tmp_scr!
1842 }
1843
1844 27126 case bosCIRCLE:
1845 default:
1846 {
1847 27126 double new_w=(w/2)+abs(w/2-x);
1848 27126 double new_h=(h/2)+abs(h/2-y);
1849 27126 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1850 //circlefill(tmp_scr,x,y,a<<3,0);
1851 27126 circlefill(tmp_scr,x,y,r,0);
1852 27126 break;
1853 }
1854 }
1855
1856 30294 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1857 30294 }
1858
1859
1860 void black_fade(int32_t fadeamnt)
1861 {
1862 for(int32_t i=0; i < 0xEF; i++)
1863 {
1864 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1865 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1866 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1867 }
1868
1869 refreshpal = true;
1870 }
1871
1872 //----------------------------------------------------------------
1873
1874 12305189 bool item_disabled(int32_t item) //is this item disabled?
1875 {
1876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12305189 times.
12305189 return (item>=0 && game->items_off[item] != 0);
1877 }
1878
1879 3474217 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1880 {
1881
2/2
✓ Branch 0 taken 20760 times.
✓ Branch 1 taken 3453457 times.
3474217 if(current_item(item_type, true) >=item)
1882 {
1883 20760 return true;
1884 }
1885
1886 3453457 return false;
1887 3474217 }
1888
1889 16377669 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1890 {
1891
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 2607818 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1831366 times.
✓ Branch 6 taken 8996078 times.
✓ Branch 7 taken 2923628 times.
✓ Branch 8 taken 18779 times.
16377669 switch(item_type)
1892 {
1893 case itype_bomb:
1894 case itype_sbomb:
1895 {
1896 int32_t itemid = getItemID(itemsbuf, item_type, it);
1897
1898 if(itemid == -1)
1899 return false;
1900
1901 return (game->get_item(itemid));
1902 }
1903
1904 case itype_clock:
1905 {
1906 2607818 int32_t itemid = getItemID(itemsbuf, item_type, it);
1907
1908
2/4
✓ Branch 0 taken 2607818 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2607818 times.
✗ Branch 3 not taken.
2607818 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
1909 return (game->get_item(itemid));
1910 2607818 return Hero.getClock()?1:0;
1911 }
1912
1913 case itype_key:
1914 return (game->get_keys()>0);
1915
1916 case itype_magiccontainer:
1917 return (game->get_maxmagic()>=game->get_mp_per_block());
1918
1919 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
1920 {
1921
1/3
✓ Branch 0 taken 1831366 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
1831366 switch(it)
1922 {
1923 case -2:
1924 {
1925 for(int32_t i=0; i<MAXLEVELS; i++)
1926 {
1927 if(game->lvlitems[i]&liTRIFORCE)
1928 {
1929 return true;
1930 }
1931 }
1932
1933 return false;
1934 }
1935
1936 case -1:
1937 return (game->lvlitems[dlevel]&liTRIFORCE);
1938
1939 default:
1940
2/4
✓ Branch 0 taken 1831366 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1831366 times.
1831366 if(it>=0&&it<MAXLEVELS)
1941 {
1942 1831366 return (game->lvlitems[it]&liTRIFORCE);
1943 }
1944
1945 break;
1946 }
1947
1948 return 0;
1949 }
1950
1951 case itype_map: //it: -2=any, -1=current level, other=that level
1952 {
1953
1/3
✓ Branch 0 taken 8996078 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
8996078 switch(it)
1954 {
1955 case -2:
1956 {
1957 for(int32_t i=0; i<MAXLEVELS; i++)
1958 {
1959 if(game->lvlitems[i]&liMAP)
1960 {
1961 return true;
1962 }
1963 }
1964
1965 return false;
1966 }
1967
1968 case -1:
1969 return (game->lvlitems[dlevel]&liMAP)!=0;
1970
1971 default:
1972
2/4
✓ Branch 0 taken 8996078 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8996078 times.
8996078 if(it>=0&&it<MAXLEVELS)
1973 {
1974 8996078 return (game->lvlitems[it]&liMAP)!=0;
1975 }
1976
1977 break;
1978 }
1979
1980 return 0;
1981 }
1982
1983 case itype_compass: //it: -2=any, -1=current level, other=that level
1984 {
1985
1/3
✓ Branch 0 taken 2923628 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
2923628 switch(it)
1986 {
1987 case -2:
1988 {
1989 for(int32_t i=0; i<MAXLEVELS; i++)
1990 {
1991 if(game->lvlitems[i]&liCOMPASS)
1992 {
1993 return true;
1994 }
1995 }
1996
1997 return false;
1998 }
1999
2000 case -1:
2001 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2002
2003 default:
2004
2/4
✓ Branch 0 taken 2923628 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2923628 times.
✗ Branch 3 not taken.
2923628 if(it>=0&&it<MAXLEVELS)
2005 {
2006 2923628 return (game->lvlitems[it]&liCOMPASS)!=0;
2007 }
2008
2009 break;
2010 }
2011 return 0;
2012 }
2013
2014 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2015 {
2016
1/3
✓ Branch 0 taken 18779 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
18779 switch(it)
2017 {
2018 case -2:
2019 {
2020 for(int32_t i=0; i<MAXLEVELS; i++)
2021 {
2022 if(game->lvlitems[i]&liBOSSKEY)
2023 {
2024 return true;
2025 }
2026 }
2027
2028 return false;
2029 }
2030
2031 case -1:
2032 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2033
2034 default:
2035
2/4
✓ Branch 0 taken 18779 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18779 times.
18779 if(it>=0&&it<MAXLEVELS)
2036 {
2037 18779 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2038 }
2039 break;
2040 }
2041 return 0;
2042 }
2043
2044 default:
2045 //it=(1<<(it-1));
2046 /*if (item_type>=itype_max)
2047 {
2048 system_pal();
2049 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,lfont);
2050 game_pal();
2051
2052 return false;
2053 }*/
2054 int32_t itemid = getItemID(itemsbuf, item_type, it);
2055
2056 if(itemid == -1)
2057 return false;
2058
2059 return game->get_item(itemid);
2060 }
2061 16377669 }
2062
2063
2064 45049062 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2065 {
2066
9/9
✓ Branch 0 taken 2607818 times.
✓ Branch 1 taken 24186518 times.
✓ Branch 2 taken 2607818 times.
✓ Branch 3 taken 2607818 times.
✓ Branch 4 taken 2607818 times.
✓ Branch 5 taken 2607818 times.
✓ Branch 6 taken 2607818 times.
✓ Branch 7 taken 2607818 times.
✓ Branch 8 taken 2607818 times.
45049062 switch(item_type)
2067 {
2068 case itype_clock:
2069 {
2070 2607818 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2071
2072
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2607818 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2607818 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2073 return itemsbuf[maxid].fam_type;
2074
2075 2607818 return has_item(itype_clock,1) ? 1 : 0;
2076 }
2077
2078 case itype_key:
2079 2607818 return game->get_keys();
2080
2081 case itype_lkey:
2082 2607818 return game->lvlkeys[get_dlevel()];
2083
2084 case itype_magiccontainer:
2085 2607818 return game->get_maxmagic()/game->get_mp_per_block();
2086
2087 case itype_triforcepiece:
2088 {
2089 2607818 int32_t count=0;
2090
2091
2/2
✓ Branch 0 taken 1335202816 times.
✓ Branch 1 taken 2607818 times.
1337810634 for(int32_t i=0; i<MAXLEVELS; i++)
2092 {
2093 1335202816 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2094 1335202816 }
2095
2096 2607818 return count;
2097 }
2098
2099 case itype_map:
2100 {
2101 2607818 int32_t count=0;
2102
2103
2/2
✓ Branch 0 taken 1335202816 times.
✓ Branch 1 taken 2607818 times.
1337810634 for(int32_t i=0; i<MAXLEVELS; i++)
2104 {
2105 1335202816 count+=(game->lvlitems[i]&liMAP)?1:0;
2106 1335202816 }
2107
2108 2607818 return count;
2109 }
2110
2111 case itype_compass:
2112 {
2113 2607818 int32_t count=0;
2114
2115
2/2
✓ Branch 0 taken 1335202816 times.
✓ Branch 1 taken 2607818 times.
1337810634 for(int32_t i=0; i<MAXLEVELS; i++)
2116 {
2117 1335202816 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2118 1335202816 }
2119
2120 2607818 return count;
2121 }
2122
2123 case itype_bosskey:
2124 {
2125 2607818 int32_t count=0;
2126
2127
2/2
✓ Branch 0 taken 1335202816 times.
✓ Branch 1 taken 2607818 times.
1337810634 for(int32_t i=0; i<MAXLEVELS; i++)
2128 {
2129 1335202816 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2130 1335202816 }
2131
2132 2607818 return count;
2133 }
2134
2135 default:
2136 24186518 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2137
2138
2/2
✓ Branch 0 taken 5443342 times.
✓ Branch 1 taken 18743176 times.
24186518 if(maxid == -1)
2139 18743176 return 0;
2140
2141 5443342 return itemsbuf[maxid].fam_type;
2142 }
2143 45049062 }
2144
2145 41574845 int32_t current_item(int32_t item_type) //item currently being used
2146 {
2147 41574845 return current_item(item_type, true);
2148 }
2149
2150 23 std::map<int32_t, int32_t> itemcache;
2151
2152 // Not actually used by anything at the moment...
2153 void removeFromItemCache(int32_t itemid)
2154 {
2155 itemcache.erase(itemid);
2156 }
2157
2158 12368 void flushItemCache()
2159 {
2160 12368 itemcache.clear();
2161
2162 //also fix the active subscreen if items were deleted -DD
2163
1/2
✓ Branch 0 taken 12368 times.
✗ Branch 1 not taken.
12368 if(game != NULL)
2164 {
2165 12368 verifyBothWeapons();
2166 12368 load_Sitems(&QMisc);
2167 12368 }
2168 12368 }
2169
2170 // This is used often, so it should be as direct as possible.
2171 1464482412 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2172 {
2173
2/2
✓ Branch 0 taken 1428857512 times.
✓ Branch 1 taken 35624900 times.
1464482412 if(jinx_check)
2174 {
2175
4/4
✓ Branch 0 taken 21560028 times.
✓ Branch 1 taken 14064872 times.
✓ Branch 2 taken 18153002 times.
✓ Branch 3 taken 3407026 times.
35624900 if(!(HeroSwordClk() || HeroItemClk()))
2176 18153002 jinx_check = false; //not jinxed
2177 35624900 }
2178
4/4
✓ Branch 0 taken 1453090009 times.
✓ Branch 1 taken 11392403 times.
✓ Branch 2 taken 17347370 times.
✓ Branch 3 taken 1435742639 times.
1464482412 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2179 {
2180 1435742639 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2181
2182
2/2
✓ Branch 0 taken 1429428661 times.
✓ Branch 1 taken 6313978 times.
1435742639 if(res != itemcache.end())
2183 1429428661 return res->second;
2184 6313978 }
2185
2186 35053751 int32_t result = -1;
2187 35053751 int32_t highestlevel = -1;
2188
2189
2/2
✓ Branch 0 taken 8973760256 times.
✓ Branch 1 taken 35053751 times.
9008814007 for(int32_t i=0; i<MAXITEMS; i++)
2190 {
2191
5/6
✓ Branch 0 taken 739513962 times.
✓ Branch 1 taken 8234246294 times.
✓ Branch 2 taken 11967588 times.
✓ Branch 3 taken 727546374 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11967588 times.
8973760256 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2192 {
2193
4/4
✓ Branch 0 taken 3040685 times.
✓ Branch 1 taken 8926903 times.
✓ Branch 2 taken 917455 times.
✓ Branch 3 taken 11050133 times.
11967588 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2194 {
2195 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2196
2/2
✓ Branch 0 taken 11050025 times.
✓ Branch 1 taken 108 times.
11050133 if(!checkmagiccost(i))
2197 {
2198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if ( !get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2199 }
2200 11050025 }
2201
6/6
✓ Branch 0 taken 10137748 times.
✓ Branch 1 taken 1829732 times.
✓ Branch 2 taken 180198 times.
✓ Branch 3 taken 1649534 times.
✓ Branch 4 taken 1165339 times.
✓ Branch 5 taken 664393 times.
11967480 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2202 {
2203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 664393 times.
664393 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2204 664393 continue;
2205 }
2206
2207
2/2
✓ Branch 0 taken 177180 times.
✓ Branch 1 taken 11125907 times.
11303087 if(itemsbuf[i].fam_type >= highestlevel)
2208 {
2209 11125907 highestlevel = itemsbuf[i].fam_type;
2210 11125907 result=i;
2211 11125907 }
2212 11303087 }
2213 8973095755 }
2214
2215
2/2
✓ Branch 0 taken 17471898 times.
✓ Branch 1 taken 17581853 times.
35053751 if(!jinx_check) //Can't cache jinx_check results
2216 17581853 itemcache[itemtype] = result;
2217 35053751 return result;
2218 1464482412 }
2219
2220 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2221 1447247820 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2222 {
2223 1447247820 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2224
2/2
✓ Branch 0 taken 18390308 times.
✓ Branch 1 taken 1428857512 times.
1447247820 if(!jinx_check) //If not already a jinx-immune-only check...
2225 {
2226 //And the player IS jinxed...
2227
4/4
✓ Branch 0 taken 1414980284 times.
✓ Branch 1 taken 13877228 times.
✓ Branch 2 taken 3357364 times.
✓ Branch 3 taken 1411622920 times.
1428857512 if(HeroSwordClk() || HeroItemClk())
2228 {
2229 //Then do a jinx-immune-only check here
2230 17234592 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2231 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2232 //Should NOT need a compat rule, as this should always return -1 in old quests.
2233
2/2
✓ Branch 0 taken 799717 times.
✓ Branch 1 taken 16434875 times.
17234592 if(ret2 > -1) return ret2;
2234 16434875 }
2235 1428057795 }
2236 1446448103 return ret;
2237 1447247820 }
2238 10751703 int32_t current_item_power(int32_t itemtype)
2239 {
2240 10751703 int32_t result = current_item_id(itemtype,true);
2241
2/2
✓ Branch 0 taken 7520312 times.
✓ Branch 1 taken 3231391 times.
10751703 return (result<0) ? 0 : itemsbuf[result].power;
2242 }
2243
2244 5 int32_t heart_container_id()
2245 {
2246
1/2
✓ Branch 0 taken 145 times.
✗ Branch 1 not taken.
145 for(int32_t i=0; i<MAXITEMS; i++)
2247 {
2248
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 140 times.
145 if(itemsbuf[i].family == itype_heartcontainer)
2249 {
2250 5 return i;
2251 }
2252 140 }
2253 return -1;
2254 5 }
2255
2256 2607818 int32_t item_tile_mod()
2257 {
2258 2607818 int32_t tile=0;
2259
2260
2/2
✓ Branch 0 taken 495310 times.
✓ Branch 1 taken 2112508 times.
2607818 if(game->get_bombs())
2261 {
2262 2112508 int32_t itemid = current_item_id(itype_bomb,false);
2263
3/4
✓ Branch 0 taken 2031449 times.
✓ Branch 1 taken 81059 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2031449 times.
2112508 if(itemid > -1 && checkbunny(itemid))
2264 2031449 tile+=itemsbuf[itemid].ltm;
2265 2112508 }
2266
2267
2/2
✓ Branch 0 taken 2169029 times.
✓ Branch 1 taken 438789 times.
2607818 if(game->get_sbombs())
2268 {
2269 438789 int32_t itemid = current_item_id(itype_sbomb,false);
2270
3/4
✓ Branch 0 taken 437361 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 437361 times.
438789 if(itemid > -1 && checkbunny(itemid))
2271 437361 tile+=itemsbuf[itemid].ltm;
2272 438789 }
2273
2274
2/2
✓ Branch 0 taken 2530549 times.
✓ Branch 1 taken 77269 times.
2607818 if(current_item(itype_clock))
2275 {
2276 77269 int32_t itemid =
2277
1/2
✓ Branch 0 taken 77269 times.
✗ Branch 1 not taken.
77269 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2278 ? iClock
2279 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2280
2/4
✓ Branch 0 taken 77269 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 77269 times.
77269 if(itemid > -1 && checkbunny(itemid))
2281 77269 tile+=itemsbuf[itemid].ltm;
2282 77269 }
2283
2284
2/2
✓ Branch 0 taken 2015550 times.
✓ Branch 1 taken 592268 times.
2607818 if(current_item(itype_key))
2285 {
2286 592268 int32_t itemid =
2287
1/2
✓ Branch 0 taken 592268 times.
✗ Branch 1 not taken.
592268 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2288 ? iKey
2289 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2290
2/4
✓ Branch 0 taken 592268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 592268 times.
592268 if(itemid > -1 && checkbunny(itemid))
2291 592268 tile+=itemsbuf[itemid].ltm;
2292 592268 }
2293
2294
2/2
✓ Branch 0 taken 2474257 times.
✓ Branch 1 taken 133561 times.
2607818 if(current_item(itype_lkey))
2295 {
2296 133561 int32_t itemid =
2297
2/2
✓ Branch 0 taken 132651 times.
✓ Branch 1 taken 910 times.
133561 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2298 ? iLevelKey
2299 910 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2300
2/4
✓ Branch 0 taken 133561 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 133561 times.
133561 if(itemid > -1 && checkbunny(itemid))
2301 133561 tile+=itemsbuf[itemid].ltm;
2302 133561 }
2303
2304
2/2
✓ Branch 0 taken 401864 times.
✓ Branch 1 taken 2205954 times.
2607818 if(current_item(itype_map))
2305 {
2306 2205954 int32_t itemid =
2307
2/2
✓ Branch 0 taken 2205168 times.
✓ Branch 1 taken 786 times.
2205954 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2308 ? iMap
2309 786 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2310
2/4
✓ Branch 0 taken 2205954 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2205954 times.
2205954 if(itemid > -1 && checkbunny(itemid))
2311 2205954 tile+=itemsbuf[itemid].ltm;
2312 2205954 }
2313
2314
2/2
✓ Branch 0 taken 319161 times.
✓ Branch 1 taken 2288657 times.
2607818 if(current_item(itype_compass))
2315 {
2316 2288657 int32_t itemid =
2317
2/2
✓ Branch 0 taken 2207598 times.
✓ Branch 1 taken 81059 times.
2288657 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2318 ? iCompass
2319 81059 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2320
2/4
✓ Branch 0 taken 2288657 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2288657 times.
2288657 if(itemid > -1 && checkbunny(itemid))
2321 2288657 tile+=itemsbuf[itemid].ltm;
2322 2288657 }
2323
2324
2/2
✓ Branch 0 taken 797456 times.
✓ Branch 1 taken 1810362 times.
2607818 if(current_item(itype_bosskey))
2325 {
2326 1810362 int32_t itemid =
2327
1/2
✓ Branch 0 taken 1810362 times.
✗ Branch 1 not taken.
1810362 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2328 ? iBossKey
2329 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2330
2/4
✓ Branch 0 taken 1810362 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1810362 times.
1810362 if(itemid > -1 && checkbunny(itemid))
2331 1810362 tile+=itemsbuf[itemid].ltm;
2332 1810362 }
2333
2334
2/2
✓ Branch 0 taken 2083798 times.
✓ Branch 1 taken 524020 times.
2607818 if(current_item(itype_magiccontainer))
2335 {
2336 524020 int32_t itemid =
2337
2/2
✓ Branch 0 taken 442175 times.
✓ Branch 1 taken 81845 times.
524020 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2338 ? iMagicC
2339 81845 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2340
2/4
✓ Branch 0 taken 524020 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 524020 times.
524020 if(itemid > -1 && checkbunny(itemid))
2341 524020 tile+=itemsbuf[itemid].ltm;
2342 524020 }
2343
2344
2/2
✓ Branch 0 taken 631231 times.
✓ Branch 1 taken 1976587 times.
2607818 if(current_item(itype_triforcepiece))
2345 {
2346 1976587 int32_t itemid =
2347
1/2
✓ Branch 0 taken 1976587 times.
✗ Branch 1 not taken.
1976587 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2348 ? iTriforce
2349 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2350
2/4
✓ Branch 0 taken 1976587 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1976587 times.
1976587 if(itemid > -1 && checkbunny(itemid))
2351 1976587 tile+=itemsbuf[itemid].ltm;
2352 1976587 }
2353
2354
2/2
✓ Branch 0 taken 2607818 times.
✓ Branch 1 taken 1335202816 times.
1337810634 for(int32_t i=0; i<itype_max; i++)
2355 {
2356
2/2
✓ Branch 0 taken 1284996096 times.
✓ Branch 1 taken 50206720 times.
1335202816 if(!get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS))
2357 {
2358
2/2
✓ Branch 0 taken 980600 times.
✓ Branch 1 taken 49226120 times.
50206720 switch(i)
2359 {
2360 case itype_bomb:
2361 case itype_sbomb:
2362 case itype_clock:
2363 case itype_key:
2364 case itype_lkey:
2365 case itype_map:
2366 case itype_compass:
2367 case itype_bosskey:
2368 case itype_magiccontainer:
2369 case itype_triforcepiece:
2370 980600 continue; //already handled
2371 }
2372 49226120 }
2373 1334222216 int32_t itemid = current_item_id(i,false);
2374
2/2
✓ Branch 0 taken 1331614398 times.
✓ Branch 1 taken 2607818 times.
1334222216 if(i == itype_shield)
2375 2607818 itemid = getCurrentShield(false);
2376
2377
3/4
✓ Branch 0 taken 37605095 times.
✓ Branch 1 taken 1296617121 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37605095 times.
1334222216 if(itemid < 0 || !checkbunny(itemid))
2378 1296617121 continue;
2379
2380 37605095 itemdata const& itm = itemsbuf[itemid];
2381
2382
2/2
✓ Branch 0 taken 35286376 times.
✓ Branch 1 taken 2318719 times.
37605095 switch(itm.family)
2383 {
2384 case itype_shield:
2385
1/2
✓ Branch 0 taken 2318719 times.
✗ Branch 1 not taken.
2318719 if(itm.flags & ITEM_FLAG9) //active shield
2386 {
2387 if(!usingActiveShield(itemid))
2388 {
2389 tile+=itm.misc6; //'Inactive PTM'
2390 continue;
2391 }
2392 }
2393 2318719 break;
2394 }
2395
2396 37605095 tile+=itm.ltm;
2397 37605095 }
2398
2399 2607818 return tile;
2400 }
2401
2402 2607818 int32_t bunny_tile_mod()
2403 {
2404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2607818 times.
2607818 if(Hero.BunnyClock())
2405 {
2406 return game->get_bunny_ltm();
2407 }
2408 2607818 return 0;
2409 2607818 }
2410
2411 // Hints are drawn on a separate layer to combo reveals.
2412 8618 void draw_lens_under(BITMAP *dest, bool layer)
2413 {
2414 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2415 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2416 //Lens flag 3: Don't show armos/chest/dive items
2417 //Lens flag 4: Show Raft Paths
2418 //Lens flag 5: Show Invisible Enemies
2419
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8618 times.
✓ Branch 2 taken 4309 times.
✓ Branch 3 taken 4309 times.
8618 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2420
2421 8618 int32_t strike_hint_table[11]=
2422 {
2423 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2424 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2425 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2426 };
2427
2428 // int32_t page = tmpscr->cpage;
2429 {
2430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8618 times.
8618 int32_t blink_rate=((get_bit(quest_rules,qr_EPILEPSY) || epilepsyFlashReduction)?6:1);
2431 // int32_t temptimer=0;
2432 8618 int32_t tempitem, tempweapon=0;
2433 8618 strike_hint=strike_hint_table[strike_hint_counter];
2434
2435
2/2
✓ Branch 0 taken 8358 times.
✓ Branch 1 taken 260 times.
8618 if(strike_hint_timer>32)
2436 {
2437 260 strike_hint_timer=0;
2438 260 strike_hint_counter=((strike_hint_counter+1)%11);
2439 260 }
2440
2441 8618 ++strike_hint_timer;
2442
2443
2/2
✓ Branch 0 taken 1516768 times.
✓ Branch 1 taken 8618 times.
1525386 for(int32_t i=0; i<176; i++)
2444 {
2445 1516768 int32_t x = (i & 15) << 4;
2446 1516768 int32_t y = (i & 0xF0) + playing_field_offset;
2447 1516768 int32_t tempitemx=-16, tempitemy=-16;
2448 1516768 int32_t tempweaponx=-16, tempweapony=-16;
2449
2450
2/2
✓ Branch 0 taken 3033536 times.
✓ Branch 1 taken 1516768 times.
4550304 for(int32_t iter=0; iter<2; ++iter)
2451 {
2452 3033536 int32_t checkflag=0;
2453
2454
2/2
✓ Branch 0 taken 1516768 times.
✓ Branch 1 taken 1516768 times.
3033536 if(iter==0)
2455 {
2456 1516768 checkflag=combobuf[tmpscr->data[i]].flag;
2457 1516768 }
2458 else
2459 {
2460 1516768 checkflag=tmpscr->sflag[i];
2461 }
2462
2463
2/2
✓ Branch 0 taken 3033152 times.
✓ Branch 1 taken 384 times.
3033536 if(checkflag==mfSTRIKE)
2464 {
2465
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 192 times.
384 if(!hints)
2466 {
2467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2468 192 }
2469 else
2470 {
2471 192 checkflag = strike_hint;
2472 }
2473 384 }
2474
2475
19/36
✓ Branch 0 taken 2997346 times.
✓ Branch 1 taken 2638 times.
✓ Branch 2 taken 2016 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28392 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 118 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 17 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 192 times.
3033536 switch(checkflag)
2476 {
2477 case 0:
2478 case mfZELDA:
2479 case mfPUSHED:
2480 case mfENEMY0:
2481 case mfENEMY1:
2482 case mfENEMY2:
2483 case mfENEMY3:
2484 case mfENEMY4:
2485 case mfENEMY5:
2486 case mfENEMY6:
2487 case mfENEMY7:
2488 case mfENEMY8:
2489 case mfENEMY9:
2490 case mfSINGLE:
2491 case mfSINGLE16:
2492 case mfNOENEMY:
2493 case mfTRAP_H:
2494 case mfTRAP_V:
2495 case mfTRAP_4:
2496 case mfTRAP_LR:
2497 case mfTRAP_UD:
2498 case mfNOGROUNDENEMY:
2499 case mfNOBLOCKS:
2500 case mfSCRIPT1:
2501 case mfSCRIPT2:
2502 case mfSCRIPT3:
2503 case mfSCRIPT4:
2504 case mfSCRIPT5:
2505 case mfSCRIPT6:
2506 case mfSCRIPT7:
2507 case mfSCRIPT8:
2508 case mfSCRIPT9:
2509 case mfSCRIPT10:
2510 case mfSCRIPT11:
2511 case mfSCRIPT12:
2512 case mfSCRIPT13:
2513 case mfSCRIPT14:
2514 case mfSCRIPT15:
2515 case mfSCRIPT16:
2516 case mfSCRIPT17:
2517 case mfSCRIPT18:
2518 case mfSCRIPT19:
2519 case mfSCRIPT20:
2520 case mfPITHOLE:
2521 case mfPITFALLFLOOR:
2522 case mfLAVA:
2523 case mfICE:
2524 case mfICEDAMAGE:
2525 case mfDAMAGE1:
2526 case mfDAMAGE2:
2527 case mfDAMAGE4:
2528 case mfDAMAGE8:
2529 case mfDAMAGE16:
2530 case mfDAMAGE32:
2531 case mfFREEZEALL:
2532 case mfFREZEALLANSFFCS:
2533 case mfFREEZEFFCSOLY:
2534 case mfSCRITPTW1TRIG:
2535 case mfSCRITPTW2TRIG:
2536 case mfSCRITPTW3TRIG:
2537 case mfSCRITPTW4TRIG:
2538 case mfSCRITPTW5TRIG:
2539 case mfSCRITPTW6TRIG:
2540 case mfSCRITPTW7TRIG:
2541 case mfSCRITPTW8TRIG:
2542 case mfSCRITPTW9TRIG:
2543 case mfSCRITPTW10TRIG:
2544 case mfTROWEL:
2545 case mfTROWELNEXT:
2546 case mfTROWELSPECIALITEM:
2547 case mfSLASHPOT:
2548 case mfLIFTPOT:
2549 case mfLIFTORSLASH:
2550 case mfLIFTROCK:
2551 case mfLIFTROCKHEAVY:
2552 case mfDROPITEM:
2553 case mfSPECIALITEM:
2554 case mfDROPKEY:
2555 case mfDROPLKEY:
2556 case mfDROPCOMPASS:
2557 case mfDROPMAP:
2558 case mfDROPBOSSKEY:
2559 case mfSPAWNNPC:
2560 case mfSWITCHHOOK:
2561 case mfSIDEVIEWLADDER:
2562 case mfSIDEVIEWPLATFORM:
2563 case mfNOENEMYSPAWN:
2564 case mfENEMYALL:
2565 case mfNOMIRROR:
2566 case mfUNSAFEGROUND:
2567 case mf168:
2568 case mf169:
2569 case mf170:
2570 case mf171:
2571 case mf172:
2572 case mf173:
2573 case mf174:
2574 case mf175:
2575 case mf176:
2576 case mf177:
2577 case mf178:
2578 case mf179:
2579 case mf180:
2580 case mf181:
2581 case mf182:
2582 case mf183:
2583 case mf184:
2584 case mf185:
2585 case mf186:
2586 case mf187:
2587 case mf188:
2588 case mf189:
2589 case mf190:
2590 case mf191:
2591 case mf192:
2592 case mf193:
2593 case mf194:
2594 case mf195:
2595 case mf196:
2596 case mf197:
2597 case mf198:
2598 case mf199:
2599 case mf200:
2600 case mf201:
2601 case mf202:
2602 case mf203:
2603 case mf204:
2604 case mf205:
2605 case mf206:
2606 case mf207:
2607 case mf208:
2608 case mf209:
2609 case mf210:
2610 case mf211:
2611 case mf212:
2612 case mf213:
2613 case mf214:
2614 case mf215:
2615 case mf216:
2616 case mf217:
2617 case mf218:
2618 case mf219:
2619 case mf220:
2620 case mf221:
2621 case mf222:
2622 case mf223:
2623 case mf224:
2624 case mf225:
2625 case mf226:
2626 case mf227:
2627 case mf228:
2628 case mf229:
2629 case mf230:
2630 case mf231:
2631 case mf232:
2632 case mf233:
2633 case mf234:
2634 case mf235:
2635 case mf236:
2636 case mf237:
2637 case mf238:
2638 case mf239:
2639 case mf240:
2640 case mf241:
2641 case mf242:
2642 case mf243:
2643 case mf244:
2644 case mf245:
2645 case mf246:
2646 case mf247:
2647 case mf248:
2648 case mf249:
2649 case mf250:
2650 case mf251:
2651 case mf252:
2652 case mf253:
2653 case mf254:
2654 case mfEXTENDED:
2655 2997346 break;
2656
2657 case mfPUSHUD:
2658 case mfPUSHLR:
2659 case mfPUSH4:
2660 case mfPUSHU:
2661 case mfPUSHD:
2662 case mfPUSHL:
2663 case mfPUSHR:
2664 case mfPUSHUDNS:
2665 case mfPUSHLRNS:
2666 case mfPUSH4NS:
2667 case mfPUSHUNS:
2668 case mfPUSHDNS:
2669 case mfPUSHLNS:
2670 case mfPUSHRNS:
2671 case mfPUSHUDINS:
2672 case mfPUSHLRINS:
2673 case mfPUSH4INS:
2674 case mfPUSHUINS:
2675 case mfPUSHDINS:
2676 case mfPUSHLINS:
2677 case mfPUSHRINS:
2678
3/4
✓ Branch 0 taken 1319 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1319 times.
2638 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2679
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1319 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1319 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2680 {
2681 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2682 }
2683
2684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2638 times.
2638 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2685
3/6
✓ Branch 0 taken 1150 times.
✓ Branch 1 taken 1488 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1488 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2638 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2686 {
2687
2/2
✓ Branch 0 taken 575 times.
✓ Branch 1 taken 575 times.
1150 if(hints)
2688 {
2689
3/3
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 42 times.
✓ Branch 2 taken 485 times.
575 switch(combobuf[tmpscr->data[i]].type)
2690 {
2691 case cPUSH_HEAVY:
2692 case cPUSH_HW:
2693 48 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2694 48 tempitemx=x, tempitemy=y;
2695
2696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(tempitem>-1)
2697 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2698
2699 48 break;
2700
2701 case cPUSH_HEAVY2:
2702 case cPUSH_HW2:
2703 42 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2704 42 tempitemx=x, tempitemy=y;
2705
2706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(tempitem>-1)
2707 42 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2708
2709 42 break;
2710 }
2711 575 }
2712 1150 }
2713
2714 2638 break;
2715
2716 case mfWHISTLE:
2717 if(hints)
2718 {
2719 tempitem=getItemID(itemsbuf,itype_whistle,1);
2720
2721 if(tempitem<0) break;
2722
2723 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2724 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2725 {
2726 tempitemx=x;
2727 tempitemy=y;
2728 }
2729
2730 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2731 }
2732
2733 break;
2734
2735 //Why is this here?
2736 case mfFAIRY:
2737 case mfMAGICFAIRY:
2738 case mfALLFAIRY:
2739 if(hints)
2740 {
2741 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2742
2743 if(tempitem < 0) break;
2744
2745 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2746 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2747 {
2748 tempitemx=x;
2749 tempitemy=y;
2750 }
2751
2752 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2753 }
2754
2755 break;
2756
2757 case mfBCANDLE:
2758
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2759 {
2760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2761 252 }
2762 else
2763 {
2764 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2765
2766
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2767
2768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2769
3/6
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2770 {
2771 126 tempitemx=x;
2772 126 tempitemy=y;
2773 126 }
2774
2775 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2776 }
2777
2778 504 break;
2779
2780 case mfRCANDLE:
2781 if(!hints)
2782 {
2783 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2784 }
2785 else
2786 {
2787 tempitem=getItemID(itemsbuf,itype_candle,2);
2788
2789 if(tempitem<0) break;
2790
2791 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2792 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2793 {
2794 tempitemx=x;
2795 tempitemy=y;
2796 }
2797
2798 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2799 }
2800
2801 break;
2802
2803 case mfWANDFIRE:
2804 if(!hints)
2805 {
2806 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2807 }
2808 else
2809 {
2810 tempitem=getItemID(itemsbuf,itype_wand,1);
2811
2812 if(tempitem<0) break;
2813
2814 tempweapon=wFire;
2815
2816 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2817 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2818 {
2819 tempitemx=x;
2820 tempitemy=y;
2821 }
2822 else
2823 {
2824 tempweaponx=x;
2825 tempweapony=y;
2826 }
2827
2828 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2829 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2830 }
2831
2832 break;
2833
2834 case mfDINSFIRE:
2835 if(!hints)
2836 {
2837 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDINSFIRE],tmpscr->secretcset[sDINSFIRE]);
2838 }
2839 else
2840 {
2841 tempitem=getItemID(itemsbuf,itype_dinsfire,1);
2842
2843 if(tempitem<0) break;
2844
2845 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2846 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2847 {
2848 tempitemx=x;
2849 tempitemy=y;
2850 }
2851
2852 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2853 }
2854
2855 break;
2856
2857 case mfARROW:
2858
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 36 times.
118 if(!hints)
2859 {
2860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2861 36 }
2862 else
2863 {
2864 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
2865
2866
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
2867
2868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2869
3/6
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 40 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2870 {
2871 42 tempitemx=x;
2872 42 tempitemy=y;
2873 42 }
2874
2875 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2876 }
2877
2878 118 break;
2879
2880 case mfSARROW:
2881 if(!hints)
2882 {
2883 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
2884 }
2885 else
2886 {
2887 tempitem=getItemID(itemsbuf,itype_arrow,2);
2888
2889 if(tempitem<0) break;
2890
2891 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2892 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2893 {
2894 tempitemx=x;
2895 tempitemy=y;
2896 }
2897
2898 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2899 }
2900
2901 break;
2902
2903 case mfGARROW:
2904 if(!hints)
2905 {
2906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
2907 }
2908 else
2909 {
2910 tempitem=getItemID(itemsbuf,itype_arrow,3);
2911
2912 if(tempitem<0) break;
2913
2914 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2915 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2916 {
2917 tempitemx=x;
2918 tempitemy=y;
2919 }
2920
2921 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2922 }
2923
2924 break;
2925
2926 case mfBOMB:
2927
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
2928 {
2929 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
2930 }
2931 else
2932 {
2933 //tempitem=getItemID(itemsbuf,itype_bomb,1);
2934 17 tempweapon = wLitBomb;
2935
2936 //if (tempitem<0) break;
2937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2938
3/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2939 {
2940 8 tempweaponx=x;
2941 8 tempweapony=y;
2942 8 }
2943
2944 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2945 }
2946
2947 17 break;
2948
2949 case mfSBOMB:
2950
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
2951 {
2952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
2953 48 }
2954 else
2955 {
2956 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
2957 //if (tempitem<0) break;
2958 48 tempweapon = wLitSBomb;
2959
2960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2961
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2962 {
2963 24 tempweaponx=x;
2964 24 tempweapony=y;
2965 24 }
2966
2967 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2968 }
2969
2970 96 break;
2971
2972 case mfARMOS_SECRET:
2973
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
2974 {
2975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
2976 12 }
2977 24 break;
2978
2979 case mfBRANG:
2980
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
2981 {
2982 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
2983 }
2984 else
2985 {
2986 5 tempitem=getItemID(itemsbuf,itype_brang,1);
2987
2988
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
2989
2990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2991
3/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2992 {
2993 3 tempitemx=x;
2994 3 tempitemy=y;
2995 3 }
2996
2997 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2998 }
2999
3000 5 break;
3001
3002 case mfMBRANG:
3003 if(!hints)
3004 {
3005 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3006 }
3007 else
3008 {
3009 tempitem=getItemID(itemsbuf,itype_brang,2);
3010
3011 if(tempitem<0) break;
3012
3013 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3014 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3015 {
3016 tempitemx=x;
3017 tempitemy=y;
3018 }
3019
3020 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3021 }
3022
3023 break;
3024
3025 case mfFBRANG:
3026 if(!hints)
3027 {
3028 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3029 }
3030 else
3031 {
3032 tempitem=getItemID(itemsbuf,itype_brang,3);
3033
3034 if(tempitem<0) break;
3035
3036 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3037 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3038 {
3039 tempitemx=x;
3040 tempitemy=y;
3041 }
3042
3043 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3044 }
3045
3046 break;
3047
3048 case mfWANDMAGIC:
3049 if(!hints)
3050 {
3051 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3052 }
3053 else
3054 {
3055 tempitem=getItemID(itemsbuf,itype_wand,1);
3056
3057 if(tempitem<0) break;
3058
3059 tempweapon=itemsbuf[tempitem].wpn3;
3060
3061 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3062 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3063 {
3064 tempitemx=x;
3065 tempitemy=y;
3066 }
3067 else
3068 {
3069 tempweaponx=x;
3070 tempweapony=y;
3071 --lens_hint_weapon[wMagic][4];
3072
3073 if(lens_hint_weapon[wMagic][4]<-8)
3074 {
3075 lens_hint_weapon[wMagic][4]=8;
3076 }
3077 }
3078
3079 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3080 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3081 }
3082
3083 break;
3084
3085 case mfREFMAGIC:
3086
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3087 {
3088 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3089 }
3090 else
3091 {
3092 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3093
3094
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3095
3096 16 tempweapon=ewMagic;
3097
3098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3099
3/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3100 {
3101 8 tempitemx=x;
3102 8 tempitemy=y;
3103 8 }
3104 else
3105 {
3106 8 tempweaponx=x;
3107 8 tempweapony=y;
3108
3109
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1 times.
8 if(lens_hint_weapon[ewMagic][2]==up)
3110 {
3111 1 --lens_hint_weapon[ewMagic][4];
3112 1 }
3113 else
3114 {
3115 7 ++lens_hint_weapon[ewMagic][4];
3116 }
3117
3118
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(lens_hint_weapon[ewMagic][4]>8)
3119 {
3120 lens_hint_weapon[ewMagic][2]=up;
3121 }
3122
3123
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
8 if(lens_hint_weapon[ewMagic][4]<=0)
3124 {
3125 2 lens_hint_weapon[ewMagic][2]=down;
3126 2 }
3127 }
3128
3129 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3130 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3131 }
3132
3133 16 break;
3134
3135 case mfREFFIREBALL:
3136
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3137 {
3138 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3139 }
3140 else
3141 {
3142 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3143
3144
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3145
3146 16 tempweapon=ewFireball;
3147
3148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3149
3/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3150 {
3151 8 tempitemx=x;
3152 8 tempitemy=y;
3153 8 tempweaponx=x;
3154 8 tempweapony=y;
3155 8 ++lens_hint_weapon[ewFireball][3];
3156
3157
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(lens_hint_weapon[ewFireball][3]>8)
3158 {
3159 lens_hint_weapon[ewFireball][3]=-8;
3160 lens_hint_weapon[ewFireball][4]=8;
3161 }
3162
3163
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(lens_hint_weapon[ewFireball][3]>0)
3164 {
3165 8 ++lens_hint_weapon[ewFireball][4];
3166 8 }
3167 else
3168 {
3169 --lens_hint_weapon[ewFireball][4];
3170 }
3171 8 }
3172
3173 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3174 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3175 }
3176
3177 16 break;
3178
3179 case mfSWORD:
3180
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3181 {
3182 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3183 }
3184 else
3185 {
3186 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3187
3188
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3189
3190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3191
3/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3192 {
3193 3 tempitemx=x;
3194 3 tempitemy=y;
3195 3 }
3196
3197 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3198 }
3199
3200 7 break;
3201
3202 case mfWSWORD:
3203 if(!hints)
3204 {
3205 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3206 }
3207 else
3208 {
3209 tempitem=getItemID(itemsbuf,itype_sword,2);
3210
3211 if(tempitem<0) break;
3212
3213 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3214 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3215 {
3216 tempitemx=x;
3217 tempitemy=y;
3218 }
3219
3220 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3221 }
3222
3223 break;
3224
3225 case mfMSWORD:
3226 if(!hints)
3227 {
3228 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3229 }
3230 else
3231 {
3232 tempitem=getItemID(itemsbuf,itype_sword,3);
3233
3234 if(tempitem<0) break;
3235
3236 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3237 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3238 {
3239 tempitemx=x;
3240 tempitemy=y;
3241 }
3242
3243 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3244 }
3245
3246 break;
3247
3248 case mfXSWORD:
3249 if(!hints)
3250 {
3251 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3252 }
3253 else
3254 {
3255 tempitem=getItemID(itemsbuf,itype_sword,4);
3256
3257 if(tempitem<0) break;
3258
3259 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3260 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3261 {
3262 tempitemx=x;
3263 tempitemy=y;
3264 }
3265
3266 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3267 }
3268
3269 break;
3270
3271 case mfSWORDBEAM:
3272
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3273 {
3274 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3275 }
3276 else
3277 {
3278 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3279
3280
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3281
3282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3283
3/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3284 {
3285 8 tempitemx=x;
3286 8 tempitemy=y;
3287 8 }
3288
3289 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3290 }
3291
3292 16 break;
3293
3294 case mfWSWORDBEAM:
3295 if(!hints)
3296 {
3297 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3298 }
3299 else
3300 {
3301 tempitem=getItemID(itemsbuf,itype_sword,2);
3302
3303 if(tempitem<0) break;
3304
3305 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3306 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3307 {
3308 tempitemx=x;
3309 tempitemy=y;
3310 }
3311
3312 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3313 }
3314
3315 break;
3316
3317 case mfMSWORDBEAM:
3318 if(!hints)
3319 {
3320 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3321 }
3322 else
3323 {
3324 tempitem=getItemID(itemsbuf,itype_sword,3);
3325
3326 if(tempitem<0) break;
3327
3328 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3329 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3330 {
3331 tempitemx=x;
3332 tempitemy=y;
3333 }
3334
3335 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3336 }
3337
3338 break;
3339
3340 case mfXSWORDBEAM:
3341 if(!hints)
3342 {
3343 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3344 }
3345 else
3346 {
3347 tempitem=getItemID(itemsbuf,itype_sword,4);
3348
3349 if(tempitem<0) break;
3350
3351 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3352 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3353 {
3354 tempitemx=x;
3355 tempitemy=y;
3356 }
3357
3358 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3359 }
3360
3361 break;
3362
3363 case mfHOOKSHOT:
3364
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3365 {
3366 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3367 }
3368 else
3369 {
3370 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3371
3372
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3373
3374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3375
3/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3376 {
3377 9 tempitemx=x;
3378 9 tempitemy=y;
3379 9 }
3380
3381 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3382 }
3383
3384 17 break;
3385
3386 case mfWAND:
3387
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3388 {
3389 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3390 }
3391 else
3392 {
3393 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3394
3395
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3396
3397
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3398
3/6
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3399 {
3400 17 tempitemx=x;
3401 17 tempitemy=y;
3402 17 }
3403
3404 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3405 }
3406
3407 35 break;
3408
3409 case mfHAMMER:
3410
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3411 {
3412 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3413 }
3414 else
3415 {
3416 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3417
3418
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3419
3420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3421
3/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3422 {
3423 8 tempitemx=x;
3424 8 tempitemy=y;
3425 8 }
3426
3427 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3428 }
3429
3430 17 break;
3431
3432 case mfARMOS_ITEM:
3433 case mfDIVE_ITEM:
3434
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3435 {
3436 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3437 2064 }
3438 2064 break;
3439
3440 case 16:
3441 case 17:
3442 case 18:
3443 case 19:
3444 case 20:
3445 case 21:
3446 case 22:
3447 case 23:
3448 case 24:
3449 case 25:
3450 case 26:
3451 case 27:
3452 case 28:
3453 case 29:
3454 case 30:
3455 case 31:
3456
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 1008 times.
2016 if(!hints)
3457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1008 times.
2016 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3458 1008 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3459
3460 2016 break;
3461 case mfSECRETSNEXT:
3462 if(!hints)
3463 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3464 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3465
3466 break;
3467
3468 case mfSTRIKE:
3469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3470 {
3471 192 goto special;
3472 }
3473 else
3474 {
3475 break;
3476 }
3477
3478 28392 default: goto special;
3479
3480 special:
3481
8/8
✓ Branch 0 taken 14196 times.
✓ Branch 1 taken 14388 times.
✓ Branch 2 taken 108 times.
✓ Branch 3 taken 14088 times.
✓ Branch 4 taken 84 times.
✓ Branch 5 taken 24 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8004 times.
28584 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3482 {
3483
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6192 times.
✓ Branch 2 taken 3096 times.
✓ Branch 3 taken 3096 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3096 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6192 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3484 {
3485 3096 rectfill(dest,x,y,x+15,y+15,WHITE);
3486 3096 }
3487 6192 }
3488
3489 28584 break;
3490 }
3491 3033536 }
3492 1516768 }
3493
3494
2/2
✓ Branch 0 taken 4309 times.
✓ Branch 1 taken 4309 times.
8618 if(layer)
3495 {
3496
2/2
✓ Branch 0 taken 4201 times.
✓ Branch 1 taken 108 times.
4309 if(tmpscr->door[0]==dWALK)
3497 108 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3498
3499
2/2
✓ Branch 0 taken 4201 times.
✓ Branch 1 taken 108 times.
4309 if(tmpscr->door[1]==dWALK)
3500 108 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3501
3502
1/2
✓ Branch 0 taken 4309 times.
✗ Branch 1 not taken.
4309 if(tmpscr->door[2]==dWALK)
3503 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3504
3505
1/2
✓ Branch 0 taken 4309 times.
✗ Branch 1 not taken.
4309 if(tmpscr->door[3]==dWALK)
3506 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3507
3508
2/2
✓ Branch 0 taken 4285 times.
✓ Branch 1 taken 24 times.
4309 if(tmpscr->door[0]==dBOMB)
3509 {
3510 24 showbombeddoor(dest, 0);
3511 24 }
3512
3513
2/2
✓ Branch 0 taken 4285 times.
✓ Branch 1 taken 24 times.
4309 if(tmpscr->door[1]==dBOMB)
3514 {
3515 24 showbombeddoor(dest, 1);
3516 24 }
3517
3518
1/2
✓ Branch 0 taken 4309 times.
✗ Branch 1 not taken.
4309 if(tmpscr->door[2]==dBOMB)
3519 {
3520 showbombeddoor(dest, 2);
3521 }
3522
3523
1/2
✓ Branch 0 taken 4309 times.
✗ Branch 1 not taken.
4309 if(tmpscr->door[3]==dBOMB)
3524 {
3525 showbombeddoor(dest, 3);
3526 }
3527 4309 }
3528
3529
2/2
✓ Branch 0 taken 6796 times.
✓ Branch 1 taken 1822 times.
8618 if(tmpscr->stairx + tmpscr->stairy)
3530 {
3531
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 911 times.
1822 if(!hints)
3532 {
3533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 911 times.
911 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3534 911 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3535 911 }
3536 else
3537 {
3538
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3539 {
3540 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3541 48 int32_t tempitemx=-16;
3542 48 int32_t tempitemy=-16;
3543
3544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3545
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 48 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3546 {
3547 tempitemx=tmpscr->stairx;
3548 tempitemy=tmpscr->stairy+playing_field_offset;
3549 }
3550
3551 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3552 48 }
3553 }
3554 1822 }
3555 }
3556 8618 }
3557
3558 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3559
3560 4140 void draw_lens_over()
3561 {
3562 // Oh, what the heck.
3563 static BITMAP *lens_scr = NULL;
3564 static int32_t last_width = -1;
3565 4140 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3566
3567 // Only redraw the circle if the size has changed
3568
2/2
✓ Branch 0 taken 4138 times.
✓ Branch 1 taken 2 times.
4140 if(width != last_width)
3569 {
3570
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(lens_scr == NULL)
3571 {
3572 2 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3573 2 }
3574
3575 2 clear_to_color(lens_scr, BLACK);
3576 2 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3577 2 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3578 2 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3579 2 last_width=width;
3580 2 }
3581
3582 4140 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3583 4140 }
3584
3585 //----------------------------------------------------------------
3586
3587 30701 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3588 {
3589 //recreating a big bitmap every frame is highly sluggish.
3590
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 30699 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
30701 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3591 30701 clear_to_color(wavebuf, BLACK);
3592 30701 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3593
3594 int32_t ofs;
3595 // int32_t amplitude=8;
3596 // int32_t wavelength=4;
3597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30701 times.
30701 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3598
2/6
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30701 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30701 if((epilepsyFlashReduction || get_bit(quest_rules,qr_EPILEPSY)) && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3599 30701 int32_t amp2=168;
3600
2/4
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30701 times.
✗ Branch 3 not taken.
30701 if((epilepsyFlashReduction || get_bit(quest_rules,qr_EPILEPSY)) && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3601 30701 int32_t i=frame%amp2;
3602
3603
2/2
✓ Branch 0 taken 5157768 times.
✓ Branch 1 taken 30701 times.
5188469 for(int32_t j=0; j<168; j++)
3604 {
3605
3/4
✓ Branch 0 taken 2578884 times.
✓ Branch 1 taken 2578884 times.
✓ Branch 2 taken 2578884 times.
✗ Branch 3 not taken.
5157768 if(j&1 && interpol)
3606 {
3607 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3608 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3609 }
3610 else
3611 {
3612 5157768 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3613 }
3614
3615
1/2
✓ Branch 0 taken 5157768 times.
✗ Branch 1 not taken.
5157768 if(ofs)
3616 {
3617
2/2
✓ Branch 0 taken 1320388608 times.
✓ Branch 1 taken 5157768 times.
1325546376 for(int32_t k=0; k<256; k++)
3618 {
3619 1320388608 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3620 1320388608 }
3621 5157768 }
3622 5157768 }
3623 30701 }
3624
3625 576 void draw_fuzzy(int32_t fuzz)
3626 // draws from right half of scrollbuf to framebuf
3627 {
3628 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3629 byte *start, *si, *di;
3630
3631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 576 times.
576 if(fuzz<1)
3632 fuzz = 1;
3633
3634 576 xstep = 128%fuzz;
3635
3636
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 456 times.
576 if(xstep > 0)
3637 456 xstep = fuzz-xstep;
3638
3639 576 ystep = 112%fuzz;
3640
3641
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 408 times.
576 if(ystep > 0)
3642 408 ystep = fuzz-ystep;
3643
3644 576 firsty = 1;
3645
3646
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 20784 times.
21360 for(y=0; y<224;)
3647 {
3648 20784 start = &(scrollbuf->line[y][256]);
3649
3650
4/4
✓ Branch 0 taken 20496 times.
✓ Branch 1 taken 129312 times.
✓ Branch 2 taken 129024 times.
✓ Branch 3 taken 20784 times.
149808 for(dy=0; dy<ystep && dy+y<224; dy++)
3651 {
3652 129024 si = start;
3653 129024 di = &(framebuf->line[y+dy][0]);
3654 129024 i = xstep;
3655 129024 firstx = 1;
3656
3657
2/2
✓ Branch 0 taken 33030144 times.
✓ Branch 1 taken 129024 times.
33159168 for(dx=0; dx<256; dx++)
3658 {
3659 33030144 *(di++) = *si;
3660
3661
2/2
✓ Branch 0 taken 27831552 times.
✓ Branch 1 taken 5198592 times.
33030144 if(++i >= fuzz)
3662 {
3663
2/2
✓ Branch 0 taken 5069568 times.
✓ Branch 1 taken 129024 times.
5198592 if(!firstx)
3664 5069568 si += fuzz;
3665 else
3666 {
3667 129024 si += fuzz-xstep;
3668 129024 firstx = 0;
3669 }
3670
3671 5198592 i = 0;
3672 5198592 }
3673 33030144 }
3674 129024 }
3675
3676
2/2
✓ Branch 0 taken 20208 times.
✓ Branch 1 taken 576 times.
20784 if(!firsty)
3677 20208 y += fuzz;
3678 else
3679 {
3680 576 y += ystep;
3681 576 ystep = fuzz;
3682 576 firsty = 0;
3683 }
3684 }
3685 576 }
3686
3687 4329467 void updatescr(bool allowwavy)
3688 {
3689
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 4329444 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
✓ Branch 4 taken 23 times.
✗ Branch 5 not taken.
4329467 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3690
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 4329444 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
4329467 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3691
3692
2/2
✓ Branch 0 taken 4303763 times.
✓ Branch 1 taken 25704 times.
4329467 if(toogam)
3693 {
3694 25704 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3695 25704 }
3696
3697
1/2
✓ Branch 0 taken 4329467 times.
✗ Branch 1 not taken.
4329467 if(Showpal)
3698 dump_pal(framebuf);
3699
3700
2/2
✓ Branch 0 taken 4269952 times.
✓ Branch 1 taken 59515 times.
4329467 if(!Playing)
3701 59515 black_opening_count=0;
3702
3703
2/2
✓ Branch 0 taken 4308413 times.
✓ Branch 1 taken 21054 times.
4329467 if(black_opening_count<0) //shape is opening up
3704 {
3705 21054 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3706
3707
2/4
✓ Branch 0 taken 21054 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21054 times.
21054 if(Advance||(!Paused))
3708 {
3709 21054 ++black_opening_count;
3710 21054 }
3711 21054 }
3712
2/2
✓ Branch 0 taken 4299173 times.
✓ Branch 1 taken 9240 times.
4308413 else if(black_opening_count>0) //shape is closing
3713 {
3714 9240 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3715
3716
2/4
✓ Branch 0 taken 9240 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9240 times.
9240 if(Advance||(!Paused))
3717 {
3718 9240 --black_opening_count;
3719 9240 }
3720 9240 }
3721
3722
3/4
✓ Branch 0 taken 4299632 times.
✓ Branch 1 taken 29835 times.
✓ Branch 2 taken 4299632 times.
✗ Branch 3 not taken.
4329467 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3723 {
3724 black_opening_shape = bosCIRCLE;
3725 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3726 refreshTints();
3727 refreshpal=true;
3728 }
3729
3730
2/2
✓ Branch 0 taken 4225883 times.
✓ Branch 1 taken 103584 times.
4329467 if(refreshpal)
3731 {
3732 103584 refreshpal=false;
3733 103584 RAMpal[253] = _RGB(0,0,0);
3734 103584 RAMpal[254] = _RGB(63,63,63);
3735 103584 hw_palette = &RAMpal;
3736 103584 update_hw_pal = true;
3737
3738 103584 create_rgb_table(&rgb_table, RAMpal, NULL);
3739 103584 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3740 103584 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3741
3742
2/2
✓ Branch 0 taken 26517504 times.
✓ Branch 1 taken 103584 times.
26621088 for(int32_t q=0; q<PAL_SIZE; q++)
3743 {
3744 26517504 trans_table2.data[0][q] = q;
3745 26517504 trans_table2.data[q][q] = q;
3746 26517504 }
3747 103584 }
3748
3749 4329467 bool clearwavy = (wavy <= 0);
3750
3751
2/2
✓ Branch 0 taken 7245 times.
✓ Branch 1 taken 4322222 times.
4329467 if(wavy <= 0)
3752 {
3753 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3754 4322222 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3755 4322222 }
3756
3757 4329467 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3758
3759
6/6
✓ Branch 0 taken 30951 times.
✓ Branch 1 taken 4298516 times.
✓ Branch 2 taken 30829 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 30701 times.
4329467 if(wavy && Playing && allowwavy)
3760 {
3761 30701 draw_wavy(framebuf, wavybuf, wavy,false);
3762 30701 }
3763
3764
2/2
✓ Branch 0 taken 4322222 times.
✓ Branch 1 taken 7245 times.
4329467 if(clearwavy)
3765 4322222 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3766
2/4
✓ Branch 0 taken 7245 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7245 times.
7245 else if(Playing && !Paused)
3767 7245 wavy--; // Wavy was set by a script. Decrement it.
3768
3769
5/6
✓ Branch 0 taken 4269952 times.
✓ Branch 1 taken 59515 times.
✓ Branch 2 taken 78694 times.
✓ Branch 3 taken 4191258 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 78694 times.
4329467 if(Playing && msgpos && !screenscrolling)
3770 {
3771
1/2
✓ Branch 0 taken 78694 times.
✗ Branch 1 not taken.
78694 if(!(msg_bg_display_buf->clip))
3772 78694 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3773
1/2
✓ Branch 0 taken 78694 times.
✗ Branch 1 not taken.
78694 if(!(msg_portrait_display_buf->clip))
3774 78694 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3775
1/2
✓ Branch 0 taken 78694 times.
✗ Branch 1 not taken.
78694 if(!(msg_txt_display_buf->clip))
3776 78694 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3777 78694 }
3778
3779 /*
3780 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3781 {
3782 BITMAP* subBmp = 0;
3783 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3784 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3785 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3786 destroy_bitmap(subBmp);
3787 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3788 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3789 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3790 }
3791 */
3792
3793
2/2
✓ Branch 0 taken 4314338 times.
✓ Branch 1 taken 15129 times.
4329467 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3794
3795
2/2
✓ Branch 0 taken 4314338 times.
✓ Branch 1 taken 15129 times.
4329467 if(nosubscr)
3796 {
3797 15129 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3798 15129 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3799 15129 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3800 15129 }
3801
3802 //TODO: Optimize blit 'overcalls' -Gleeok
3803
2/2
✓ Branch 0 taken 15129 times.
✓ Branch 1 taken 4314338 times.
4329467 BITMAP *source = nosubscr ? panorama : wavybuf;
3804 4329467 blit(source,framebuf,0,0,0,0,256,224);
3805
3806 4329467 update_hw_screen();
3807 4329467 }
3808
3809 //----------------------------------------------------------------
3810
3811 PALETTE sys_pal;
3812
3813 int32_t onGUISnapshot()
3814 {
3815 char buf[200];
3816 int32_t num=0;
3817 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3818 do
3819 {
3820 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3821 }
3822 while(num<99999 && exists(buf));
3823
3824 BITMAP *b = create_bitmap_ex(8,resx,resy);
3825
3826 if(b)
3827 {
3828 if(MenuOpen)
3829 {
3830 //Cannot load game's palette while GUI elements are in focus. -Z
3831 //If there is a way to do this, then I have missed it.
3832 /*
3833 game_pal();
3834 RAMpal[253] = _RGB(0,0,0);
3835 RAMpal[254] = _RGB(63,63,63);
3836 set_palette_range(RAMpal,0,255,false);
3837 memcpy(RAMpal, snappal, sizeof(snappal));
3838 create_rgb_table(&rgb_table, RAMpal, NULL);
3839 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3840 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3841
3842 for(int32_t q=0; q<PAL_SIZE; q++)
3843 {
3844 trans_table2.data[0][q] = q;
3845 trans_table2.data[q][q] = q;
3846 }
3847 */
3848 //ringcolor(false);
3849 //get_palette(RAMpal);
3850 blit(screen,b,0,0,0,0,resx,resy);
3851 //al_trace("Menu Open\n");
3852 //game_pal();
3853 //PALETTE temppal;
3854 //get_palette(temppal);
3855 //system_pal();
3856 save_bitmap(buf,b,sys_pal);
3857 //save_bitmap(buf,b,RAMpal);
3858 //save_bitmap(buf,b,snappal);
3859 }
3860 else
3861 {
3862 blit(screen,b,0,0,0,0,resx,resy);
3863 save_bitmap(buf,b,realpal?sys_pal:RAMpal);
3864 }
3865 destroy_bitmap(b);
3866 }
3867
3868 return D_O_K;
3869 }
3870
3871 int32_t onNonGUISnapshot()
3872 {
3873 PALETTE temppal;
3874 get_palette(temppal);
3875 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3876
3877 char buf[200];
3878 int32_t num=0;
3879
3880 do
3881 {
3882 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3883 }
3884 while(num<99999 && exists(buf));
3885
3886 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3887
3888 return D_O_K;
3889 }
3890
3891 int32_t onSnapshot()
3892 {
3893 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3894 {
3895 onGUISnapshot();
3896 }
3897 else
3898 {
3899 onNonGUISnapshot();
3900 }
3901
3902 return D_O_K;
3903 }
3904
3905 int32_t onSaveMapPic()
3906 {
3907 int32_t mapres2 = 0;
3908 char buf[200];
3909 int32_t num=0;
3910 mapscr tmpscr_b[2];
3911 mapscr tmpscr_c[6];
3912 BITMAP* _screen_draw_buffer = NULL;
3913 _screen_draw_buffer = create_bitmap_ex(8,256,224);
3914 set_clip_state(_screen_draw_buffer,1);
3915
3916 for(int32_t i=0; i<6; ++i)
3917 {
3918 tmpscr_c[i] = tmpscr2[i];
3919 tmpscr2[i].zero_memory();
3920
3921 if(i>=2)
3922 {
3923 continue;
3924 }
3925
3926 tmpscr_b[i] = tmpscr[i];
3927 tmpscr[i].zero_memory();
3928 }
3929
3930 do
3931 {
3932 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
3933 }
3934 while(num<99999 && exists(buf));
3935
3936 BITMAP* mappic = NULL;
3937
3938
3939 bool done=false, redraw=true;
3940
3941 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
3942
3943 if(!mappic)
3944 {
3945 system_pal();
3946 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
3947 game_pal();
3948 return D_O_K;;
3949 }
3950
3951 // draw the map
3952 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
3953
3954 for(int32_t y=0; y<8; y++)
3955 {
3956 for(int32_t x=0; x<16; x++)
3957 {
3958 if(!displayOnMap(x, y))
3959 {
3960 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
3961 }
3962 else
3963 {
3964 int32_t s = (y<<4) + x;
3965 loadscr2(1,s,-1);
3966
3967 for(int32_t i=0; i<6; i++)
3968 {
3969 if(tmpscr[1].layermap[i]<=0)
3970 continue;
3971
3972 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
3973 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
3974 {
3975 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
3976
3977 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
3978 }
3979 }
3980
3981 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
3982
3983 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
3984
3985 putscr(_screen_draw_buffer,256,0,tmpscr+1);
3986 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
3987
3988 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
3989
3990 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
3991 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
3992 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
3993 {
3994 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
3995 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
3996 }
3997 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
3998
3999 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4000
4001 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4002 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4003 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
4004 {
4005 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4006 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4007 }
4008 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4009 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4010
4011 }
4012
4013 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4014 }
4015 }
4016
4017 for(int32_t i=0; i<6; ++i)
4018 {
4019 tmpscr2[i]=tmpscr_c[i];
4020
4021 if(i>=2)
4022 {
4023 continue;
4024 }
4025
4026 tmpscr[i]=tmpscr_b[i];
4027 }
4028
4029 save_bitmap(buf,mappic,RAMpal);
4030 destroy_bitmap(mappic);
4031 destroy_bitmap(_screen_draw_buffer);
4032 return D_O_K;
4033 }
4034
4035 /*
4036 int32_t onSaveMapPic()
4037 {
4038 BITMAP* mappic = NULL;
4039 BITMAP* _screen_draw_buffer = NULL;
4040 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4041 int32_t mapres2 = 0;
4042 char buf[20];
4043 int32_t num=0;
4044 set_clip_state(_screen_draw_buffer,1);
4045 set_clip_rect(_screen_draw_buffer,0,0,_screen_draw_buffer->w, _screen_draw_buffer->h);
4046
4047 do
4048 {
4049 sprintf(buf, "zelda%03d.png", ++num);
4050 }
4051 while(num<999 && exists(buf));
4052
4053 // if(!mappic) {
4054 mappic = create_bitmap_ex(8,(256*16)>>mapres2,(176*8)>>mapres2);
4055
4056 if(!mappic)
4057 {
4058 system_pal();
4059 jwin_alert("Save Map Picture","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
4060 game_pal();
4061 return D_O_K;
4062 }
4063
4064 // }
4065
4066 int32_t layermap, layerscreen;
4067 int32_t x2=0;
4068
4069 // draw the map
4070 for(int32_t y=0; y<8; y++)
4071 {
4072 for(int32_t x=0; x<16; x++)
4073 {
4074 int32_t s = (y<<4) + x;
4075
4076 if(!displayOnMap(x, y))
4077 {
4078 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4079 }
4080 else
4081 {
4082 loadscr(TEMPSCR_FUNCTION_SWAP_SPACE,currdmap,s,-1,false);
4083 putscr(_screen_draw_buffer, 0, 0, tmpscr+1);
4084
4085 for(int32_t k=0; k<4; k++)
4086 {
4087 if(k==2)
4088 {
4089 putscrdoors(_screen_draw_buffer, 0, 0, tmpscr+1);
4090 }
4091
4092 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4093
4094 if(layermap>-1)
4095 {
4096 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4097
4098 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4099 {
4100 for(int32_t i=0; i<176; i++)
4101 {
4102 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4103 }
4104 }
4105 else
4106 {
4107 for(int32_t i=0; i<176; i++)
4108 {
4109 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4110 }
4111 }
4112 }
4113 }
4114
4115 for(int32_t i=0; i<176; i++)
4116 {
4117 // if (COMBOTYPE((i&15)<<4,i&0xF0)==cOLD_OVERHEAD)
4118 if(combo_class_buf[COMBOTYPE((i&15)<<4,i&0xF0)].overhead)
4119 {
4120 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),MAPCOMBO((i&15)<<4,i&0xF0),MAPCSET((i&15)<<4,i&0xF0));
4121 }
4122 }
4123
4124 for(int32_t k=4; k<6; k++)
4125 {
4126 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4127
4128 if(layermap>-1)
4129 {
4130 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4131
4132 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4133 {
4134 for(int32_t i=0; i<176; i++)
4135 {
4136 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4137 }
4138 }
4139 else
4140 {
4141 for(int32_t i=0; i<176; i++)
4142 {
4143 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4144 }
4145 }
4146 }
4147 }
4148 }
4149
4150 stretch_blit(_screen_draw_buffer, mappic, 0, 0, 256, 176,
4151 x<<(8-mapres2), (y*176)>>mapres2, 256>>mapres2, 176>>mapres2);
4152 }
4153
4154 }
4155
4156 save_bitmap(buf,mappic,RAMpal);
4157 destroy_bitmap(mappic);
4158 destroy_bitmap(_screen_draw_buffer);
4159 return D_O_K;
4160 }
4161 */
4162
4163 14 void f_Quit(int32_t type)
4164 {
4165
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(type==qQUIT && !Playing)
4166 return;
4167
4168 14 bool from_menu = is_sys_pal;
4169
4170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4171 {
4172 14 music_pause();
4173 14 pause_all_sfx();
4174 14 }
4175 14 enter_sys_pal();
4176 14 clear_keybuf();
4177
4178 14 replay_poll();
4179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (replay_is_replaying())
4180 14 replay_peek_quit();
4181
4182
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (!replay_is_replaying())
4183 switch(type)
4184 {
4185 case qQUIT:
4186 onQuit();
4187 break;
4188
4189 case qRESET:
4190 onReset();
4191 break;
4192
4193 case qEXIT:
4194 onExit();
4195 break;
4196 }
4197
4198
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(Quit)
4199 {
4200 14 kill_sfx();
4201 14 music_stop();
4202 14 exit_sys_pal();
4203 14 update_hw_screen();
4204 14 }
4205 else
4206 {
4207 exit_sys_pal();
4208 if(!from_menu)
4209 {
4210 music_resume();
4211 resume_all_sfx();
4212 }
4213 }
4214
4215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4216 14 show_mouse(NULL);
4217 14 eat_buttons();
4218
4219 14 zc_readrawkey(KEY_ESC);
4220
4221 14 zc_readrawkey(KEY_ENTER);
4222 14 }
4223
4224 //----------------------------------------------------------------
4225
4226 int32_t onNoWalls()
4227 {
4228 cheats_enqueue(Cheat::Walls);
4229 return D_O_K;
4230 }
4231
4232 int32_t onIgnoreSideview()
4233 {
4234 cheats_enqueue(Cheat::IgnoreSideView);
4235 return D_O_K;
4236 }
4237
4238 4391070 int32_t input_idle(bool checkmouse)
4239 {
4240 static int32_t mx, my, mz, mb;
4241
4242
4/6
✓ Branch 0 taken 4391070 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 990988 times.
✓ Branch 3 taken 3400082 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 990988 times.
5382058 if(keypressed() || zc_key_pressed() ||
4243
4/8
✓ Branch 0 taken 990988 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 990988 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 990988 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 990988 times.
✗ Branch 7 not taken.
990988 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4244 {
4245 3400082 idle_count = 0;
4246
4247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3400082 times.
3400082 if(active_count < MAX_ACTIVE)
4248 {
4249 3400082 ++active_count;
4250 3400082 }
4251 3400082 }
4252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 990988 times.
990988 else if(idle_count < MAX_IDLE)
4253 {
4254 990988 ++idle_count;
4255 990988 active_count = 0;
4256 990988 }
4257
4258 4391070 mx = mouse_x;
4259 4391070 my = mouse_y;
4260 4391070 mz = mouse_z;
4261 4391070 mb = mouse_b;
4262
4263 4391070 return idle_count;
4264 }
4265
4266 int32_t onGoFast()
4267 {
4268 cheats_enqueue(Cheat::Fast);
4269 return D_O_K;
4270 }
4271
4272 int32_t onKillCheat()
4273 {
4274 cheats_enqueue(Cheat::Kill);
4275 return D_O_K;
4276 }
4277
4278 int32_t onShowLayer0()
4279 {
4280 show_layer_0 = !show_layer_0;
4281 return D_O_K;
4282 }
4283 int32_t onShowLayer1()
4284 {
4285 show_layer_1 = !show_layer_1;
4286 return D_O_K;
4287 }
4288 int32_t onShowLayer2()
4289 {
4290 show_layer_2 = !show_layer_2;
4291 return D_O_K;
4292 }
4293 int32_t onShowLayer3()
4294 {
4295 show_layer_3 = !show_layer_3;
4296 return D_O_K;
4297 }
4298 int32_t onShowLayer4()
4299 {
4300 show_layer_4 = !show_layer_4;
4301 return D_O_K;
4302 }
4303 int32_t onShowLayer5()
4304 {
4305 show_layer_5 = !show_layer_5;
4306 return D_O_K;
4307 }
4308 int32_t onShowLayer6()
4309 {
4310 show_layer_6 = !show_layer_6;
4311 return D_O_K;
4312 }
4313 int32_t onShowLayerO()
4314 {
4315 show_layer_over=!show_layer_over;
4316 return D_O_K;
4317 }
4318 int32_t onShowLayerP()
4319 {
4320 show_layer_push=!show_layer_push;
4321 return D_O_K;
4322 }
4323 int32_t onShowLayerS()
4324 {
4325 show_sprites=!show_sprites;
4326 return D_O_K;
4327 }
4328 int32_t onShowLayerF()
4329 {
4330 show_ffcs=!show_ffcs;
4331 return D_O_K;
4332 }
4333 int32_t onShowLayerW()
4334 {
4335 show_walkflags=!show_walkflags;
4336 return D_O_K;
4337 }
4338 int32_t onShowLayerE()
4339 {
4340 show_effectflags=!show_effectflags;
4341 return D_O_K;
4342 }
4343 int32_t onShowFFScripts()
4344 {
4345 show_ff_scripts=!show_ff_scripts;
4346 return D_O_K;
4347 }
4348 int32_t onShowHitboxes()
4349 {
4350 show_hitboxes=!show_hitboxes;
4351 return D_O_K;
4352 }
4353
4354 int32_t onLightSwitch()
4355 {
4356 cheats_enqueue(Cheat::Light);
4357 return D_O_K;
4358 }
4359
4360 int32_t onGoTo();
4361 int32_t onGoToComplete();
4362
4363 4391070 void syskeys()
4364 {
4365 4391070 update_system_keys();
4366
4367 int32_t oldtitle_version;
4368
4369
1/2
✓ Branch 0 taken 4391070 times.
✗ Branch 1 not taken.
4391070 if(close_button_quit)
4370 {
4371 close_button_quit=false;
4372 f_Quit(qEXIT);
4373 }
4374
4375 4391070 poll_joystick();
4376
4377
2/10
✓ Branch 0 taken 4391070 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4391070 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
4391070 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4378 {
4379 oldtitle_version=title_version;
4380 System();
4381 }
4382
4383 4391070 mouse_down=gui_mouse_b();
4384
4385
1/2
✓ Branch 0 taken 4391070 times.
✗ Branch 1 not taken.
4391070 if(zc_read_system_key(KEY_F1))
4386 {
4387 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4388 {
4389 halt=!halt;
4390 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4391 }
4392 else
4393 {
4394 Throttlefps=!Throttlefps;
4395 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4396 logic_counter=0;
4397 }
4398 }
4399
4400 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4401 /*
4402 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4403 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4404 */
4405
4406
1/4
✓ Branch 0 taken 4391070 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4391070 if(zc_read_system_key(KEY_OPENBRACE)) if(frame_rest_suggest > 0) frame_rest_suggest--;
4407
4408
1/4
✓ Branch 0 taken 4391070 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4391070 if(zc_read_system_key(KEY_CLOSEBRACE)) if(frame_rest_suggest <= 2) frame_rest_suggest++;
4409
4410
1/2
✓ Branch 0 taken 4391070 times.
✗ Branch 1 not taken.
4391070 if(zc_read_system_key(KEY_F2))
4411 {
4412 ShowFPS=!ShowFPS;
4413 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4414 }
4415
4416
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4391070 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4391070 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4417
4418
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4391070 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4391070 if(zc_read_system_key(KEY_F4) && Playing)
4419 {
4420 Paused=true;
4421 Advance=true;
4422 }
4423
4424
1/2
✓ Branch 0 taken 4391070 times.
✗ Branch 1 not taken.
4391070 if(zc_read_system_key(KEY_F6)) onTryQuit();
4425
4426 #ifndef ALLEGRO_MACOSX
4427
1/2
✓ Branch 0 taken 4391070 times.
✗ Branch 1 not taken.
4391070 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4428
4429
1/2
✓ Branch 0 taken 4391070 times.
✗ Branch 1 not taken.
4391070 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4430 #else
4431 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4432
4433 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4434 #endif
4435
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 4391070 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4391070 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4436
4437
1/2
✓ Branch 0 taken 4391070 times.
✗ Branch 1 not taken.
4391070 if (zc_read_system_key(KEY_F12))
4438 {
4439 onSnapshot();
4440 }
4441
4442
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4391070 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4391070 if(debug_enabled && zc_read_system_key(KEY_TAB))
4443 set_debug(!get_debug());
4444
4445
3/4
✓ Branch 0 taken 4391070 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20926 times.
✓ Branch 3 taken 4370144 times.
4391070 if(get_debug() || cheat>=1)
4446 {
4447
1/2
✓ Branch 0 taken 20926 times.
✗ Branch 1 not taken.
20926 if( CheatModifierKeys() )
4448 {
4449 if(zc_readkey(KEY_ASTERISK) || zc_readkey(KEY_H)) cheats_enqueue(Cheat::Life, game->get_maxlife());
4450
4451 if(zc_readkey(KEY_SLASH_PAD) || zc_readkey(KEY_M)) cheats_enqueue(Cheat::Magic, game->get_maxmagic());
4452
4453 if(zc_readkey(KEY_R)) cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
4454
4455 if(zc_readkey(KEY_B))
4456 {
4457 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
4458 }
4459
4460 if(zc_readkey(KEY_A))
4461 {
4462 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
4463 }
4464 }
4465 20926 }
4466
4467
3/4
✓ Branch 0 taken 4391070 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20926 times.
✓ Branch 3 taken 4370144 times.
4391070 if(get_debug() || cheat>=2)
4468 {
4469
1/2
✓ Branch 0 taken 20926 times.
✗ Branch 1 not taken.
20926 if( CheatModifierKeys() )
4470 {
4471 if(rI())
4472 {
4473 cheats_enqueue(Cheat::Clock);
4474 }
4475 }
4476 20926 }
4477
4478
3/4
✓ Branch 0 taken 4391070 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20926 times.
✓ Branch 3 taken 4370144 times.
4391070 if(get_debug() || cheat>=4)
4479 {
4480
1/2
✓ Branch 0 taken 20926 times.
✗ Branch 1 not taken.
20926 if( CheatModifierKeys() )
4481 {
4482 if(rF11())
4483 {
4484 cheats_enqueue(Cheat::Walls);
4485 }
4486
4487 if(rQ())
4488 {
4489 cheats_enqueue(Cheat::Fast);
4490 }
4491
4492 if(zc_readkey(KEY_F))
4493 {
4494 cheats_enqueue(Cheat::Freeze);
4495 }
4496
4497 if(zc_readkey(KEY_G)) onGoToComplete();
4498
4499 if(zc_readkey(KEY_0)) onShowLayer0();
4500
4501 if(zc_readkey(KEY_1)) onShowLayer1();
4502
4503 if(zc_readkey(KEY_2)) onShowLayer2();
4504
4505 if(zc_readkey(KEY_3)) onShowLayer3();
4506
4507 if(zc_readkey(KEY_4)) onShowLayer4();
4508
4509 if(zc_readkey(KEY_5)) onShowLayer5();
4510
4511 if(zc_readkey(KEY_6)) onShowLayer6();
4512
4513 //if(zc_readkey(KEY_7)) onShowLayerO();
4514 if(zc_readkey(KEY_7)) onShowLayerF();
4515
4516 if(zc_readkey(KEY_8)) onShowLayerS();
4517
4518 if(zc_readkey(KEY_W)) onShowLayerW();
4519
4520 if(zc_readkey(KEY_L)) cheats_enqueue(Cheat::Light);
4521
4522 if(zc_readkey(KEY_V)) cheats_enqueue(Cheat::IgnoreSideView);
4523
4524 if(zc_readkey(KEY_K)) cheats_enqueue(Cheat::Kill);
4525 if(zc_readkey(KEY_O)) onShowLayerO();
4526 if(zc_readkey(KEY_P)) onShowLayerP();
4527 if(zc_readkey(KEY_C)) onShowHitboxes();
4528 if(zc_readkey(KEY_F)) onShowFFScripts();
4529 }
4530 20926 }
4531
4532
1/2
✓ Branch 0 taken 4391070 times.
✗ Branch 1 not taken.
4391070 if(volkeys)
4533 {
4534 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4535
4536 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4537
4538 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4539
4540 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4541 }
4542
4543
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4391070 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4391070 if(!get_debug() || !SystemKeys || replay_is_replaying())
4544 4391070 goto bottom;
4545
4546 if(zc_readkey(KEY_D))
4547 {
4548 details = !details;
4549 rectfill(screen,0,0,319,7,BLACK);
4550 rectfill(screen,0,8,31,239,BLACK);
4551 rectfill(screen,288,8,319,239,BLACK);
4552 rectfill(screen,32,232,287,239,BLACK);
4553 }
4554
4555 if(zc_readkey(KEY_P)) Paused=!Paused;
4556
4557 //if(zc_readkey(KEY_P)) centerHero();
4558 if(zc_readkey(KEY_A))
4559 {
4560 Paused=true;
4561 Advance=true;
4562 }
4563
4564 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4565 #ifndef ALLEGRO_MACOSX
4566 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4567
4568 if(zc_readkey(KEY_F7))
4569 {
4570 Matrix(ss_speed, ss_density, 0);
4571 game_pal();
4572 }
4573 #else
4574 // The reason these are different on Mac in the first place is that
4575 // the OS doesn't let us use F9 and F10...
4576 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4577
4578 if(zc_readkey(KEY_F9))
4579 {
4580 Matrix(ss_speed, ss_density, 0);
4581 game_pal();
4582 }
4583 #endif
4584 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4585 {
4586 //change containers
4587 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4588 {
4589 //magic containers
4590 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4591 {
4592 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4593 }
4594 else
4595 {
4596 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4597 }
4598 }
4599 else
4600 {
4601 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4602 {
4603 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4604 }
4605 else
4606 {
4607 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4608 }
4609 }
4610 }
4611
4612 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4613 {
4614 //change containers
4615 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4616 {
4617 //magic containers
4618 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4619 {
4620 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4621 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4622 //heart containers
4623 }
4624 else
4625 {
4626 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4627 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4628 }
4629 }
4630 else
4631 {
4632 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4633 {
4634 game->set_magic(zc_max(game->get_magic()-1,0));
4635 }
4636 else
4637 {
4638 game->set_life(zc_max(game->get_life()-1,0));
4639 }
4640 }
4641 }
4642
4643 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4644
4645 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4646
4647 verifyBothWeapons();
4648
4649 bottom:
4650
4651
1/2
✓ Branch 0 taken 4391070 times.
✗ Branch 1 not taken.
4391070 if(input_idle(true) > after_time())
4652 {
4653 Matrix(ss_speed, ss_density, 0);
4654 game_pal();
4655 }
4656 4391070 }
4657
4658 14372239 void checkQuitKeys()
4659 {
4660 #ifndef ALLEGRO_MACOSX
4661
1/2
✓ Branch 0 taken 14372239 times.
✗ Branch 1 not taken.
14372239 if(zc_readrawkey(KEY_F9)) f_Quit(qRESET);
4662
4663
1/2
✓ Branch 0 taken 14372239 times.
✗ Branch 1 not taken.
14372239 if(zc_readrawkey(KEY_F10)) f_Quit(qEXIT);
4664 #else
4665 if(zc_readrawkey(KEY_F7)) f_Quit(qRESET);
4666
4667 if(zc_readrawkey(KEY_F8)) f_Quit(qEXIT);
4668 #endif
4669 14372239 }
4670
4671 62778 bool CheatModifierKeys()
4672 {
4673 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4674 // to trigger cheats.
4675
1/2
✓ Branch 0 taken 62778 times.
✗ Branch 1 not taken.
62778 if (replay_is_replaying())
4676 62778 return false;
4677
4678 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4679 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4680 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4681 {
4682 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4683 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4684 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4685 {
4686 return true;
4687 }
4688 }
4689 return false;
4690 62778 }
4691
4692 //99:05:54, for some reason?
4693 #define OLDMAXTIME 21405240
4694 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4695 #define MAXTIME 1944000000
4696
4697 4329467 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4698 {
4699
2/2
✓ Branch 0 taken 4068056 times.
✓ Branch 1 taken 261411 times.
4329467 if(zcmusic!=NULL)
4700 {
4701 261411 zcmusic_poll();
4702 261411 }
4703
4704 4329467 updatescr(allowwavy);
4705
4706
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4329467 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4329467 times.
4329467 while(Paused && !Advance && !Quit)
4707 {
4708 // have to call this, otherwise we'll get an infinite loop
4709 syskeys();
4710 if(allowF6Script)
4711 {
4712 FFCore.runF6Engine();
4713 }
4714 throttleFPS();
4715
4716 #ifdef _WIN32
4717
4718 if(use_dwm_flush)
4719 {
4720 do_DwmFlush();
4721 }
4722
4723 #endif
4724
4725 // to keep music playing
4726 if(zcmusic!=NULL)
4727 {
4728 zcmusic_poll();
4729 }
4730
4731 update_hw_screen();
4732 }
4733
4734
2/2
✓ Branch 0 taken 4329444 times.
✓ Branch 1 taken 23 times.
4329467 if(Quit)
4735 23 return;
4736
4737
3/4
✓ Branch 0 taken 4269947 times.
✓ Branch 1 taken 59497 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4269947 times.
4329444 if(Playing && game->get_time()<unsigned(get_bit(quest_rules,qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4738 4269947 game->change_time(1);
4739
4740 4329444 Advance=false;
4741
4742
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 4329438 times.
4329444 if (replay_is_active())
4743 {
4744
2/2
✓ Branch 0 taken 1270457 times.
✓ Branch 1 taken 3058981 times.
4329438 if (replay_get_version() >= 3)
4745 3058981 replay_poll();
4746
4747 // Replay compatability.
4748
4/4
✓ Branch 0 taken 908786 times.
✓ Branch 1 taken 3420652 times.
✓ Branch 2 taken 808251 times.
✓ Branch 3 taken 100535 times.
4329438 if (replay_get_version() >= 6 && replay_get_version() < 8)
4749 100535 replay_peek_input();
4750 4329438 }
4751
4752 4329444 update_keys();
4753
4754 4329444 ++frame;
4755
4756
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 4329438 times.
4329444 if (replay_is_replaying())
4757 4329438 replay_do_cheats();
4758 4329444 syskeys();
4759
4760 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4761 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4762 // approach here means it doesn't matter which call adds the cheat.
4763 4329444 cheats_execute_queued();
4764
4765
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 4329438 times.
4329444 if (replay_is_replaying())
4766 4329438 replay_peek_quit();
4767
2/2
✓ Branch 0 taken 4329430 times.
✓ Branch 1 taken 14 times.
4329444 if (GameFlags & GAMEFLAG_TRYQUIT)
4768 14 replay_step_quit(0);
4769
2/2
✓ Branch 0 taken 1466 times.
✓ Branch 1 taken 4327978 times.
4329444 if(allowF6Script)
4770 {
4771 4327978 FFCore.runF6Engine();
4772 4327978 }
4773
2/2
✓ Branch 0 taken 4329314 times.
✓ Branch 1 taken 130 times.
4329444 if (Quit)
4774 130 replay_step_quit(Quit);
4775 // Someday... maybe install a Turbo button here?
4776 4329444 throttleFPS();
4777
4778 #ifdef _WIN32
4779
4780 if(use_dwm_flush)
4781 {
4782 do_DwmFlush();
4783 }
4784
4785 #endif
4786
4787 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4788
2/2
✓ Branch 0 taken 6446 times.
✓ Branch 1 taken 4322998 times.
4329444 if(sfxcleanup)
4789 4322998 sfx_cleanup();
4790 4329467 }
4791
4792 12 void zapout()
4793 {
4794 12 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4795 12 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4796
4797 12 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4798 12 script_drawing_commands.Clear();
4799
4800 // zap out
4801
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 288 times.
300 for(int32_t i=1; i<=24; i++)
4802 {
4803 288 draw_fuzzy(i);
4804 288 syskeys();
4805 288 advanceframe(true);
4806
4807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
288 if(Quit)
4808 {
4809 break;
4810 }
4811 288 }
4812 12 }
4813
4814 12 void zapin()
4815 {
4816 12 FFCore.warpScriptCheck();
4817 12 draw_screen(tmpscr);
4818 12 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4819 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4820 12 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4821
4822 // zap out
4823 12 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4824
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 288 times.
300 for(int32_t i=24; i>=1; i--)
4825 {
4826 288 draw_fuzzy(i);
4827 288 syskeys();
4828 288 advanceframe(true);
4829
4830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
288 if(Quit)
4831 {
4832 break;
4833 }
4834 288 }
4835 12 }
4836
4837
4838 23 void wavyout(bool showhero)
4839 {
4840 23 draw_screen(tmpscr, showhero);
4841 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4842
4843 23 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4844 23 clear_to_color(wavebuf,0);
4845 23 blit(framebuf,wavebuf,0,0,16,0,256,224);
4846
4847 static PALETTE wavepal;
4848
4849 int32_t ofs;
4850 23 int32_t amplitude=8;
4851
4852 23 int32_t wavelength=4;
4853 23 double palpos=0, palstep=4, palstop=126;
4854
4855 23 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4856
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 966 times.
989 for(int32_t i=0; i<168; i+=wavelength)
4857 {
4858
2/2
✓ Branch 0 taken 247296 times.
✓ Branch 1 taken 966 times.
248262 for(int32_t l=0; l<256; l++)
4859 {
4860 247296 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4861 247296 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4862 247296 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4863 247296 }
4864
4865 966 palpos+=palstep;
4866
4867
1/2
✓ Branch 0 taken 966 times.
✗ Branch 1 not taken.
966 if(palpos>=0)
4868 {
4869 966 hw_palette = &wavepal;
4870 966 update_hw_pal = true;
4871 966 }
4872 else
4873 {
4874 hw_palette = &RAMpal;
4875 update_hw_pal = true;
4876 }
4877
4878
2/2
✓ Branch 0 taken 162288 times.
✓ Branch 1 taken 966 times.
163254 for(int32_t j=0; j+playing_field_offset<224; j++)
4879 {
4880
2/2
✓ Branch 0 taken 41545728 times.
✓ Branch 1 taken 162288 times.
41708016 for(int32_t k=0; k<256; k++)
4881 {
4882 41545728 ofs=0;
4883
4884
4/4
✓ Branch 0 taken 20278272 times.
✓ Branch 1 taken 21267456 times.
✓ Branch 2 taken 10139136 times.
✓ Branch 3 taken 10139136 times.
41545728 if((j<i)&&(j&1))
4885 {
4886 10139136 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4887 10139136 }
4888
4889 41545728 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4890 41545728 }
4891 162288 }
4892
4893 966 syskeys();
4894 966 advanceframe(true);
4895
4896 // animate_combos();
4897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 966 times.
966 if(Quit)
4898 break;
4899 966 }
4900
4901 23 destroy_bitmap(wavebuf);
4902 23 }
4903
4904 23 void wavyin()
4905 {
4906 23 draw_screen(tmpscr);
4907 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4908
4909 23 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4910 23 clear_to_color(wavebuf,0);
4911 23 blit(framebuf,wavebuf,0,0,16,0,256,224);
4912
4913 static PALETTE wavepal;
4914
4915 //Breaks dark rooms.
4916 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4917 /*
4918 loadfullpal();
4919 loadlvlpal(DMaps[currdmap].color);
4920 ringcolor(false);
4921 */
4922 23 refreshpal=false;
4923 int32_t ofs;
4924 23 int32_t amplitude=8;
4925 23 int32_t wavelength=4;
4926 23 double palpos=168, palstep=4, palstop=126;
4927
4928 23 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4929
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 966 times.
989 for(int32_t i=0; i<168; i+=wavelength)
4930 {
4931
2/2
✓ Branch 0 taken 247296 times.
✓ Branch 1 taken 966 times.
248262 for(int32_t l=0; l<256; l++)
4932 {
4933 247296 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4934 247296 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4935 247296 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4936 247296 }
4937
4938 966 palpos-=palstep;
4939
4940
1/2
✓ Branch 0 taken 966 times.
✗ Branch 1 not taken.
966 if(palpos>=0)
4941 {
4942 966 hw_palette = &wavepal;
4943 966 update_hw_pal = true;
4944 966 }
4945 else
4946 {
4947 hw_palette = &RAMpal;
4948 update_hw_pal = true;
4949 }
4950
4951
2/2
✓ Branch 0 taken 162288 times.
✓ Branch 1 taken 966 times.
163254 for(int32_t j=0; j+playing_field_offset<224; j++)
4952 {
4953
2/2
✓ Branch 0 taken 41545728 times.
✓ Branch 1 taken 162288 times.
41708016 for(int32_t k=0; k<256; k++)
4954 {
4955 41545728 ofs=0;
4956
4957
4/4
✓ Branch 0 taken 21020160 times.
✓ Branch 1 taken 20525568 times.
✓ Branch 2 taken 10633728 times.
✓ Branch 3 taken 10386432 times.
41545728 if((j<(167-i))&&(j&1))
4958 {
4959 10386432 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4960 10386432 }
4961
4962 41545728 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4963 41545728 }
4964 162288 }
4965
4966 966 syskeys();
4967 966 advanceframe(true);
4968 // animate_combos();
4969
4970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 966 times.
966 if(Quit)
4971 break;
4972 966 }
4973
4974 23 destroy_bitmap(wavebuf);
4975 23 }
4976
4977 1252 void blackscr(int32_t fcnt,bool showsubscr)
4978 {
4979 1252 reset_pal_cycling();
4980 1252 script_drawing_commands.Clear();
4981
4982 1252 FFCore.warpScriptCheck();
4983 1252 bool showtime = game->should_show_time();
4984
2/2
✓ Branch 0 taken 1252 times.
✓ Branch 1 taken 37490 times.
38742 while(fcnt>0)
4985 {
4986 37490 clear_bitmap(framebuf);
4987
4988
2/2
✓ Branch 0 taken 9360 times.
✓ Branch 1 taken 28130 times.
37490 if(showsubscr)
4989 {
4990 28130 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,showtime,sspUP);
4991
3/4
✓ Branch 0 taken 28130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 27380 times.
28130 if(get_bit(quest_rules, qr_SCRIPTDRAWSINWARPS) || (get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
4992 {
4993 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
4994 750 }
4995 28130 }
4996
4997 37490 syskeys();
4998 37490 advanceframe(true);
4999
5000
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37490 times.
37490 if(Quit)
5001 break;
5002
5003 37490 --fcnt;
5004 }
5005 1252 }
5006
5007 307 void openscreen(int32_t shape)
5008 {
5009 307 reset_pal_cycling();
5010 307 black_opening_count=0;
5011
5012
3/4
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 209 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
307 if(COOLSCROLL || shape>-1)
5013 {
5014 209 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5015 209 return;
5016 }
5017 else
5018 {
5019 98 Hero.setDontDraw(true);
5020 98 show_subscreen_dmap_dots=false;
5021 98 show_subscreen_numbers=false;
5022 // show_subscreen_items=false;
5023 98 show_subscreen_life=false;
5024 }
5025
5026 98 int32_t x=128;
5027
5028 98 FFCore.warpScriptCheck();
5029
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 7840 times.
7938 for(int32_t i=0; i<80; i++)
5030 {
5031 7840 draw_screen(tmpscr);
5032 //? draw_screen already draws the subscreen -DD
5033 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5034 7840 x=128-(((i*128/80)/8)*8);
5035
5036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(x>0)
5037 {
5038 7840 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5039 7840 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5040 7840 }
5041
5042 // x=((80-i)/2)*4;
5043 /*
5044 --x;
5045 switch(++c)
5046 {
5047 case 5: c=0;
5048 case 0:
5049 case 2:
5050 case 3: --x; break;
5051 }
5052 */
5053 7840 syskeys();
5054 7840 advanceframe(true);
5055
5056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(Quit)
5057 {
5058 break;
5059 }
5060 7840 }
5061
5062 98 Hero.setDontDraw(false);
5063 98 show_subscreen_items=true;
5064 98 show_subscreen_dmap_dots=true;
5065 307 }
5066
5067 void closescreen(int32_t shape)
5068 {
5069 reset_pal_cycling();
5070 black_opening_count=0;
5071
5072 if(COOLSCROLL || shape>-1)
5073 {
5074 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5075 return;
5076 }
5077 else
5078 {
5079 Hero.setDontDraw(true);
5080 show_subscreen_dmap_dots=false;
5081 show_subscreen_numbers=false;
5082 // show_subscreen_items=false;
5083 show_subscreen_life=false;
5084 }
5085
5086 int32_t x=128;
5087
5088 FFCore.warpScriptCheck();
5089 for(int32_t i=79; i>=0; --i)
5090 {
5091 draw_screen(tmpscr);
5092 //? draw_screen already draws the subscreen -DD
5093 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5094 x=128-(((i*128/80)/8)*8);
5095
5096 if(x>0)
5097 {
5098 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5099 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5100 }
5101
5102 // x=((80-i)/2)*4;
5103 /*
5104 --x;
5105 switch(++c)
5106 {
5107 case 5: c=0;
5108 case 0:
5109 case 2:
5110 case 3: --x; break;
5111 }
5112 */
5113 syskeys();
5114 advanceframe(true);
5115
5116 if(Quit)
5117 {
5118 break;
5119 }
5120 }
5121
5122 Hero.setDontDraw(false);
5123 show_subscreen_items=true;
5124 show_subscreen_dmap_dots=true;
5125 }
5126
5127 84 int32_t TriforceCount()
5128 {
5129 84 int32_t c=0;
5130
5131
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 84 times.
756 for(int32_t i=1; i<=8; i++)
5132
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 374 times.
1046 if(game->lvlitems[i]&liTRIFORCE)
5133 374 ++c;
5134
5135 84 return c;
5136 }
5137
5138 int32_t onCustomGame()
5139 {
5140 int32_t file = getsaveslot();
5141
5142 if(file < 0)
5143 return D_O_K;
5144
5145 bool ret = (custom_game(file)!=0);
5146 return ret ? D_CLOSE : D_O_K;
5147 }
5148
5149 int32_t onContinue()
5150 {
5151 return D_CLOSE;
5152 }
5153
5154 int32_t onEsc() // Unused?? -L
5155 {
5156 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5157 }
5158
5159 int32_t onVsync()
5160 {
5161 Throttlefps = !Throttlefps;
5162 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5163 return D_O_K;
5164 }
5165
5166 int32_t onWinPosSave()
5167 {
5168 SaveWinPos = !SaveWinPos;
5169 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5170 return D_O_K;
5171 }
5172
5173 int32_t onClickToFreeze()
5174 {
5175 ClickToFreeze = !ClickToFreeze;
5176 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5177 return D_O_K;
5178 }
5179
5180 int32_t OnSaveZCConfig()
5181 {
5182 if(jwin_alert3(
5183 "Save Configuration",
5184 "Are you sure that you wish to save your present configuration settings?",
5185 "This will overwrite your prior settings!",
5186 NULL,
5187 "&Yes",
5188 "&No",
5189 NULL,
5190 'y',
5191 'n',
5192 0,
5193 lfont) == 1)
5194 {
5195 save_game_configs();
5196 return D_O_K;
5197 }
5198 else return D_O_K;
5199 }
5200
5201 int32_t OnnClearQuestDir()
5202 {
5203 if(jwin_alert3(
5204 "Clear Current Directory Cache",
5205 "Are you sure that you wish to clear the current cached directory?",
5206 "This will default the current directory to the ROOT for this instance of ZC Player!",
5207 NULL,
5208 "&Yes",
5209 "&No",
5210 NULL,
5211 'y',
5212 'n',
5213 0,
5214 lfont) == 1)
5215 {
5216 zc_set_config("zeldadx","win_qst_dir","");
5217 flush_config_file();
5218 strcpy(qstdir,"");
5219 #ifdef __EMSCRIPTEN__
5220 em_sync_fs();
5221 #endif
5222 return D_O_K;
5223 }
5224 else return D_O_K;
5225 }
5226
5227
5228 int32_t onConsoleZASM()
5229 {
5230 if ( !zasm_debugger )
5231 {
5232 AlertDialog("WARNING: ZASM Debugger",
5233 "Enabling this will open the ZASM Debugger Console"
5234 "\nThis will likely grind ZC to a halt with lag."
5235 "\nTo make any use of this, it is suggested that you read"
5236 "\nthe documentation for 'void Breakpoint(char[] string);'"
5237 " in 'ZScript_Additions.txt'"
5238 "\nThis is not recommended for normal users,"
5239 " and is only intended for ZC developers,"
5240 "\nor quest developers coding directly in ZASM"
5241 "\nAre you sure that you wish to open the ZASM Debugger?",
5242 [&](bool ret,bool)
5243 {
5244 if(ret)
5245 {
5246 FFCore.ZASMPrint(true);
5247 }
5248 }).show();
5249 return D_O_K;
5250 }
5251 else
5252 {
5253 FFCore.ZASMPrint(false);
5254 return D_O_K;
5255 }
5256 }
5257
5258
5259 int32_t onConsoleZScript()
5260 {
5261 if ( !zscript_debugger )
5262 {
5263 AlertDialog("ZScript Debugger",
5264 "Enabling this will open the ZScript Debugger Console"
5265 "\nThis will display any messages logged by scripts,"
5266 " including script errors."
5267 "\nAre you sure that you wish to open the ZScript Debugger?",
5268 [&](bool ret,bool)
5269 {
5270 if(ret)
5271 {
5272 FFCore.ZScriptConsole(true);
5273 }
5274 }).show();
5275 return D_O_K;
5276 }
5277 else
5278 {
5279 FFCore.ZScriptConsole(false);
5280 return D_O_K;
5281 }
5282 }
5283
5284 int32_t onClrConsoleOnLoad()
5285 {
5286 clearConsoleOnLoad = !clearConsoleOnLoad;
5287 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5288 return D_O_K;
5289 }
5290
5291
5292 int32_t onFrameSkip()
5293 {
5294 FrameSkip = !FrameSkip;
5295 return D_O_K;
5296 }
5297
5298 int32_t onSaveDragResize()
5299 {
5300 SaveDragResize = !SaveDragResize;
5301 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5302 return D_O_K;
5303 }
5304
5305 int32_t onDragAspect()
5306 {
5307 DragAspect = !DragAspect;
5308 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5309 return D_O_K;
5310 }
5311
5312 int32_t onTransLayers()
5313 {
5314 TransLayers = !TransLayers;
5315 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5316 return D_O_K;
5317 }
5318
5319 int32_t onNESquit()
5320 {
5321 NESquit = !NESquit;
5322 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5323 return D_O_K;
5324 }
5325
5326 int32_t onVolKeys()
5327 {
5328 volkeys = !volkeys;
5329 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5330 return D_O_K;
5331 }
5332
5333 int32_t onShowFPS()
5334 {
5335 ShowFPS = !ShowFPS;
5336 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5337 return D_O_K;
5338 }
5339
5340 518146260 bool is_Fkey(int32_t k)
5341 {
5342
2/2
✓ Branch 0 taken 52692840 times.
✓ Branch 1 taken 465453420 times.
518146260 switch(k)
5343 {
5344 case KEY_F1:
5345 case KEY_F2:
5346 case KEY_F3:
5347 case KEY_F4:
5348 case KEY_F5:
5349 case KEY_F6:
5350 case KEY_F7:
5351 case KEY_F8:
5352 case KEY_F9:
5353 case KEY_F10:
5354 case KEY_F11:
5355 case KEY_F12:
5356 52692840 return true;
5357 }
5358
5359 465453420 return false;
5360 518146260 }
5361
5362 void kb_getkey(DIALOG *d)
5363 {
5364 d->flags|=D_SELECTED;
5365
5366 scare_mouse();
5367 jwin_button_proc(MSG_DRAW,d,0);
5368 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5369 // text_mode(vc(11));
5370 textout_centre_ex(gui_bmp, font, "Press a key", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5371 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5372 unscare_mouse();
5373
5374 update_hw_screen(true);
5375
5376 clear_keybuf();
5377 int32_t k = next_press_key();
5378 clear_keybuf();
5379
5380 //shnarf
5381 //47=f1
5382 //59=esc
5383 if(k>0 && k<123 && !((k>46)&&(k<60)))
5384 *((int32_t*)d->dp3) = k;
5385
5386
5387 d->flags&=~D_SELECTED;
5388 }
5389
5390
5391 //Used by all keyboard key settings dialogues.
5392 void kb_clearjoystick(DIALOG *d)
5393 {
5394 d->flags|=D_SELECTED;
5395
5396 scare_mouse();
5397 jwin_button_proc(MSG_DRAW,d,0);
5398 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5399 // text_mode(vc(11));
5400 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5401 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5402 unscare_mouse();
5403
5404 update_hw_screen(true);
5405
5406 clear_keybuf();
5407 int32_t k = next_press_key();
5408 clear_keybuf();
5409
5410 //shnarf
5411 //47=f1
5412 //59=esc
5413 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5414 // *((int32_t*)d->dp3) = k;
5415 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5416
5417
5418 d->flags&=~D_SELECTED;
5419 }
5420
5421 //Clears key to 0.
5422 //Used by all keyboard key settings dialogues.
5423 void kb_clearkey(DIALOG *d)
5424 {
5425 d->flags|=D_SELECTED;
5426
5427 scare_mouse();
5428 jwin_button_proc(MSG_DRAW,d,0);
5429 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5430 // text_mode(vc(11));
5431 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5432 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5433 unscare_mouse();
5434
5435 update_hw_screen(true);
5436
5437 clear_keybuf();
5438 int32_t k = next_press_key();
5439 clear_keybuf();
5440
5441 //shnarf
5442 //47=f1
5443 //59=esc
5444 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5445 // *((int32_t*)d->dp3) = k;
5446 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5447
5448
5449 d->flags&=~D_SELECTED;
5450 }
5451
5452
5453 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5454 {
5455 switch(msg)
5456 {
5457 case MSG_KEY:
5458 case MSG_CLICK:
5459
5460 kb_clearjoystick(d);
5461
5462 while(gui_mouse_b())
5463 {
5464 clear_keybuf();
5465 rest(1);
5466 }
5467
5468 return D_REDRAW;
5469 }
5470
5471 return jwin_button_proc(msg,d,c);
5472 }
5473
5474 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5475 {
5476 switch(msg)
5477 {
5478 case MSG_KEY:
5479 case MSG_CLICK:
5480
5481 kb_getkey(d);
5482
5483 while(gui_mouse_b()) {
5484 clear_keybuf();
5485 rest(1);
5486 }
5487
5488 return D_REDRAW;
5489 }
5490
5491 return jwin_button_proc(msg,d,c);
5492 }
5493
5494 //Only used in keyboard settings dialogues to clear keys.
5495 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5496 {
5497 switch(msg)
5498 {
5499 case MSG_KEY:
5500 case MSG_CLICK:
5501
5502 kb_clearkey(d);
5503
5504 while(gui_mouse_b()) {
5505 clear_keybuf();
5506 rest(1);
5507 }
5508
5509 return D_REDRAW;
5510 }
5511
5512 return jwin_button_proc(msg,d,c);
5513 }
5514
5515 void j_getbtn(DIALOG *d)
5516 {
5517 d->flags|=D_SELECTED;
5518 scare_mouse();
5519 jwin_button_proc(MSG_DRAW,d,0);
5520 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5521 // text_mode(vc(11));
5522 int32_t y = gui_bmp->h/2 - 12;
5523 textout_centre_ex(gui_bmp, font, "Press a button", gui_bmp->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5524 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5525 textout_centre_ex(gui_bmp, font, "SPACE to disable", gui_bmp->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5526 unscare_mouse();
5527
5528 update_hw_screen(true);
5529
5530 int32_t b = next_press_btn();
5531
5532 if(b>=0)
5533 *((int32_t*)d->dp3) = b;
5534
5535 d->flags&=~D_SELECTED;
5536
5537 if (player)
5538 player->joy_on = TRUE;
5539 }
5540
5541 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5542 {
5543 switch(msg)
5544 {
5545 case MSG_KEY:
5546 case MSG_CLICK:
5547
5548 j_getbtn(d);
5549
5550 while(gui_mouse_b()) {
5551 rest(1);
5552 clear_keybuf();
5553 }
5554
5555 return D_REDRAW;
5556 }
5557
5558 return jwin_button_proc(msg,d,c);
5559 }
5560
5561 //shnarf
5562 const char *key_str[] =
5563 {
5564 "(none) ", "a ", "b ", "c ",
5565 "d ", "e ", "f ", "g ",
5566 "h ", "i ", "j ", "k ",
5567 "l ", "m ", "n ", "o ",
5568 "p ", "q ", "r ", "s ",
5569 "t ", "u ", "v ", "w ",
5570 "x ", "y ", "z ", "0 ",
5571 "1 ", "2 ", "3 ", "4 ",
5572 "5 ", "6 ", "7 ", "8 ",
5573 "9 ", "num 0 ", "num 1 ", "num 2 ",
5574 "num 3 ", "num 4 ", "num 5 ", "num 6 ",
5575 "num 7 ", "num 8 ", "num 9 ", "f1 ",
5576 "f2 ", "f3 ", "f4 ", "f5 ",
5577 "f6 ", "f7 ", "f8 ", "f9 ",
5578 "f10 ", "f11 ", "f12 ", "esc ",
5579 "~ ", "- ", "= ", "backspace ",
5580 "tab ", "{ ", "} ", "enter ",
5581 ": ", "quote ", "\\ ", "\\ (2) ",
5582 ", ", ". ", "/ ", "space ",
5583 "insert ", "delete ", "home ", "end ",
5584 "page up ", "page down ", "left ", "right ",
5585 "up ", "down ", "num / ", "num * ",
5586 "num - ", "num + ", "num delete ", "num enter ",
5587 "print screen ", "pause ", "abnt c1 ", "yen ",
5588 "kana ", "convert ", "no convert ", "at ",
5589 "circumflex ", ": (2) ", "kanji ", "num = ",
5590 "back quote ", "; ", "command ", "unknown (0) ",
5591 "unknown (1) ", "unknown (2) ", "unknown (3) ", "unknown (4) ",
5592 "unknown (5) ", "unknown (6) ", "unknown (7) ", "left shift ",
5593 "right shift ", "left control ", "right control", "alt ",
5594 "alt gr ", "left win ", "right win ", "menu ",
5595 "scroll lock ", "number lock ", "caps lock ", "MAX"
5596 };
5597
5598
5599 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5600 //extern int32_t zcmusic_bufsz;
5601
5602 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5603 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5604
5605 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5606 {
5607 //these are here to bypass compiler warnings about unused arguments
5608 c=c;
5609
5610 if(msg==MSG_DRAW)
5611 {
5612 switch(d->w)
5613 {
5614 case 0:
5615 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5616 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5617 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5618 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5619 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5620 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5621 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5622 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5623 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5624 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5625 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5626 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5627 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5628 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5629 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5630 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5631 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5632 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5633 break;
5634
5635 case 1:
5636 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5637 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5638 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5639 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5640 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5641 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5642 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5643 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5644 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5645 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5646 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5647 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5648 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5649 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5650 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5651 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5652 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5653 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5654 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5655 break;
5656
5657 case 2:
5658 sprintf(str_a," %3d",midi_volume);
5659 sprintf(str_b," %3d",digi_volume);
5660 sprintf(str_l," %3d",emusic_volume);
5661 sprintf(str_m," %3dKB",zcmusic_bufsz);
5662 sprintf(str_r," %3d",sfx_volume);
5663 strcpy(str_s,pan_str[pan_style]);
5664 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5665 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5666 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5667 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5668 break;
5669 }
5670 }
5671
5672 return D_O_K;
5673 }
5674
5675 int32_t set_vol(void *dp3, int32_t d2)
5676 {
5677 switch(((int32_t*)dp3)[0])
5678 {
5679 case 0:
5680 midi_volume = zc_min(d2<<3,255);
5681 break;
5682
5683 case 1:
5684 digi_volume = zc_min(d2<<3,255);
5685 break;
5686
5687 case 2:
5688 emusic_volume = zc_min(d2<<3,255);
5689 break;
5690
5691 case 3:
5692 sfx_volume = zc_min(d2<<3,255);
5693 break;
5694 }
5695
5696 scare_mouse();
5697 // text_mode(vc(11));
5698 textprintf_right_ex(screen,is_large ? lfont_l : font, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5699 unscare_mouse();
5700 return D_O_K;
5701 }
5702
5703 int32_t set_pan(void *dp3, int32_t d2)
5704 {
5705 pan_style = vbound(d2,0,3);
5706 scare_mouse();
5707 // text_mode(vc(11));
5708 textout_right_ex(screen,is_large ? lfont_l : font, pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5709 unscare_mouse();
5710 return D_O_K;
5711 }
5712
5713 int32_t set_buf(void *dp3, int32_t d2)
5714 {
5715 scare_mouse();
5716 // text_mode(vc(11));
5717 zcmusic_bufsz = d2 + 1;
5718 textprintf_right_ex(screen,is_large ? lfont_l : font, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5719 unscare_mouse();
5720 return D_O_K;
5721 }
5722
5723 static int32_t gamepad_btn_list[] =
5724 {
5725 6,
5726 7,8,9,10,11,12,13,14,15,16,17,
5727 18,19,20,21,22,23,24,25,26,27,28,
5728 29,30,31,32,33,34,35,36,37,38,39,
5729 -1
5730 };
5731
5732 static int32_t gamepad_dirs_list[] =
5733 {
5734 40,41,42,43,
5735 44,45,46,47,
5736 48,49,50,51,
5737 52,53,54,55,
5738 56,
5739 -1
5740 };
5741
5742 static TABPANEL gamepad_tabs[] =
5743 {
5744 // (text)
5745 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5746 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5747 { NULL, 0, NULL, 0, NULL }
5748 };
5749
5750 static DIALOG gamepad_dlg[] =
5751 {
5752 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5753 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5754 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5755 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5756 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5757 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5758 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5759 // 6
5760 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5761 // 7
5762 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5763 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5764 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5765 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5766 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5767 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5768 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5769 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5770 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5771 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5772 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5773 // 18
5774 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5775 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5776 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5777 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5778 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5779 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5780 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5781 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5782 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5783 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5784 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5785 // 29
5786 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5787 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5788 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5789 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5790 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5791 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5792 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5793 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5794 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5795 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5796 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5797 // 40
5798 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5799 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5800 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5801 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5802 // 44
5803 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5804 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5805 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5806 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5807 // 48
5808 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5809 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5810 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5811 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5812 // 52
5813 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5814 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5815 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5816 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5817 // 56
5818 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5819 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5820 };
5821
5822 static int32_t keyboard_keys_list[] =
5823 {
5824 6,7,8,9,10,
5825 11,12,13,14,15,16,17,18,19,20,
5826 21,22,23,24,25,26,27,28,29,30,
5827 31,32,33,34,35,36,37,38,39,40,
5828 -1
5829 };
5830
5831 static int32_t keyboard_dirs_list[] =
5832 {
5833 41,42,43,44,
5834 45,46,47,48,
5835 49,50,51,52,
5836 53,54,55,56,
5837 -1
5838 };
5839
5840 static int32_t keyboard_mods_list[] =
5841 {
5842 57,58,59,60,
5843 61,62,63,64,
5844 65,66,67,68,
5845 69,70,71,72,
5846 -1
5847 };
5848
5849 static TABPANEL keyboard_control_tabs[] =
5850 {
5851 // (text)
5852 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5853 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5854 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5855 { NULL, 0, NULL, 0, NULL }
5856 };
5857
5858 static DIALOG keyboard_control_dlg[] =
5859 {
5860 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5861 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5862 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5863 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5864 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5865 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5866 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5867 // Keys
5868 // 6
5869 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5870 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5871 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5872 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5873 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5874 // 11
5875 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5876 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5877 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5878 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5879 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5880 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5881 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5882 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5883 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5884 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5885 // 21
5886 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5887 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5888 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5889 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5890 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5891 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5892 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5893 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5894 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5895 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5896 // 31
5897 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5898 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5899 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5900 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5901 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5902 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5903 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5904 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5905 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5906 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5907 // Dirs
5908 // 41
5909 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5910 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5911 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5912 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5913 // 45
5914 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5915 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5916 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5917 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5918 // 49
5919 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5920 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5921 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5922 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5923 // 53
5924 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5925 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5926 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5927 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5928 // Mods
5929 // 57
5930 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5931 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5932 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5933 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5934 // 61
5935 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5936 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5937 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5938 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5939 // 65
5940 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5941 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5942 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5943 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5944 // 69
5945 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5946 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5947 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5948 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5949 // 73
5950 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5951 };
5952
5953 /*
5954 int32_t midi_dp[3] = {0,147,104};
5955 int32_t digi_dp[3] = {1,147,120};
5956 int32_t pan_dp[3] = {0,147,136};
5957 int32_t buf_dp[3] = {0,147,152};
5958 */
5959 int32_t midi_dp[3] = {0,0,0};
5960 int32_t digi_dp[3] = {1,0,0};
5961 int32_t emus_dp[3] = {2,0,0};
5962 int32_t buf_dp[3] = {0,0,0};
5963 int32_t sfx_dp[3] = {3,0,0};
5964 int32_t pan_dp[3] = {0,0,0};
5965
5966 static DIALOG sound_dlg[] =
5967 {
5968 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5969 23 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5970 23 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5971 23 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5972 23 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5973 23 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5974 23 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5975 23 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5976 23 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5977 23 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5978 23 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5979 // 10
5980 23 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5981 23 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5982 23 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5983 23 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5984 23 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5985 23 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5986 23 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5987 23 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5988 23 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5989 23 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5990 //20
5991 23 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5992 23 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5993 23 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5994 23 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5995 23 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5996 23 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5997 23 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5998 23 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5999 23 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
6000 23 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
6001 //30
6002 23 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6003 23 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6004 23 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6005 23 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6006 };
6007
6008 char zc_builddate[80];
6009 char zc_aboutstr[80];
6010
6011 static DIALOG about_dlg[] =
6012 {
6013 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6014 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
6015 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6016 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
6017 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
6018 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
6019 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
6020 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
6021 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
6022 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
6023 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6024 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6025 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6026 };
6027
6028
6029 static DIALOG quest_dlg[] =
6030 {
6031 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6032 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
6033 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
6034 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
6035 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
6036 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
6037 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
6038 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
6039 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
6040 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
6041 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
6042 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
6043 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
6044 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6045 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6046 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6047 };
6048
6049 static DIALOG triforce_dlg[] =
6050 {
6051 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
6052 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
6053 // 1
6054 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
6055 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
6056 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
6057 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
6058 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
6059 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
6060 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
6061 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
6062 // 9
6063 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6064 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6065 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6066 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6067 };
6068
6069 /*static DIALOG equip_dlg[] =
6070 {
6071 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6072 { jwin_win_proc, 16, 18, 289, 215, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Equipment", NULL, NULL },
6073 // 1
6074 { jwin_button_proc, 90, 206, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6075 { jwin_button_proc, 170, 206, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6076 // 3
6077 { jwin_frame_proc, 25, 45, 77, 50, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6078 { jwin_text_proc, 29, 42, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Sword", NULL, NULL },
6079 { jwin_check_proc, 33, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6080 { jwin_check_proc, 33, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "White", NULL, NULL },
6081 { jwin_check_proc, 33, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6082 { jwin_check_proc, 33, 82, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Master", NULL, NULL },
6083 // 9
6084 { jwin_frame_proc, 25, 99, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6085 { jwin_text_proc, 29, 96, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Shield", NULL, NULL },
6086 { jwin_check_proc, 33, 106, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6087 { jwin_check_proc, 33, 116, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6088 { jwin_check_proc, 33, 126, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Mirror", NULL, NULL },
6089 // 14
6090 { jwin_frame_proc, 25, 143, 61, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6091 { jwin_text_proc, 29, 140, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Ring", NULL, NULL },
6092 { jwin_check_proc, 33, 150, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6093 { jwin_check_proc, 33, 160, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6094 { jwin_check_proc, 33, 170, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Gold", NULL, NULL },
6095 // 19
6096 { jwin_frame_proc, 110, 45, 85, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6097 { jwin_text_proc, 114, 42, 64, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bracelet", NULL, NULL },
6098 { jwin_check_proc, 118, 52, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6099 { jwin_check_proc, 118, 62, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 2", NULL, NULL },
6100 // 23
6101 { jwin_frame_proc, 110, 79, 85, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6102 { jwin_text_proc, 114, 76, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Amulet", NULL, NULL },
6103 { jwin_check_proc, 118, 86, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6104 { jwin_check_proc, 118, 96, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 2", NULL, NULL },
6105 // 27
6106 { jwin_frame_proc, 110, 113, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6107 { jwin_text_proc, 114, 110, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Wallet", NULL, NULL },
6108 { jwin_check_proc, 118, 120, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6109 { jwin_check_proc, 118, 130, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Large", NULL, NULL },
6110 // 31
6111 { jwin_frame_proc, 110, 147, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6112 { jwin_text_proc, 114, 144, 24, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bow", NULL, NULL },
6113 { jwin_check_proc, 118, 154, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6114 { jwin_check_proc, 118, 164, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Large", NULL, NULL },
6115 // 35
6116 { jwin_frame_proc, 203, 45, 93, 70, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6117 { jwin_text_proc, 207, 42, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Other", NULL, NULL },
6118 { jwin_check_proc, 211, 52, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Raft", NULL, NULL },
6119 { jwin_check_proc, 211, 62, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Ladder", NULL, NULL },
6120 { jwin_check_proc, 211, 72, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Book", NULL, NULL },
6121 { jwin_check_proc, 211, 82, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic Key", NULL, NULL },
6122 { jwin_check_proc, 211, 92, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Flippers", NULL, NULL },
6123 { jwin_check_proc, 211, 102, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Boots", NULL, NULL },
6124 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6125 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6126 };
6127
6128 static DIALOG items_dlg[] =
6129 {
6130 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6131 { jwin_win_proc, 16, 18, 289, 215, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Items", NULL, NULL },
6132 //1
6133 { jwin_button_proc, 90, 206, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6134 { jwin_button_proc, 170, 206, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6135 // 3
6136 { jwin_frame_proc, 27, 45, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6137 { jwin_text_proc, 31, 42, 64, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Boomerang", NULL, NULL },
6138 { jwin_check_proc, 35, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6139 { jwin_check_proc, 35, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6140 { jwin_check_proc, 35, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Fire", NULL, NULL },
6141 // 8
6142 { jwin_frame_proc, 27, 89, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6143 { jwin_text_proc, 31, 86, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Arrow", NULL, NULL },
6144 { jwin_check_proc, 35, 96, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6145 { jwin_check_proc, 35, 106, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Silver", NULL, NULL },
6146 { jwin_check_proc, 35, 116, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Golden", NULL, NULL },
6147 // 13
6148 { jwin_frame_proc, 27, 133, 63, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6149 { jwin_text_proc, 31, 130, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Potion", NULL, NULL },
6150 { jwin_radio_proc, 35, 140, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "None", NULL, NULL },
6151 { jwin_radio_proc, 35, 150, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6152 { jwin_radio_proc, 35, 160, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6153 // 18
6154 { jwin_frame_proc, 114, 45, 93, 20, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6155 { jwin_text_proc, 118, 42, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Whistle", NULL, NULL },
6156 { jwin_check_proc, 122, 52, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Recorder", NULL, NULL },
6157 // 21
6158 { jwin_frame_proc, 114, 69, 86, 20, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6159 { jwin_text_proc, 118, 66, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Hammer", NULL, NULL },
6160 { jwin_check_proc, 122, 76, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6161 // 24
6162 { jwin_frame_proc, 114, 93, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6163 { jwin_text_proc, 118, 90, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Hookshot", NULL, NULL },
6164 { jwin_check_proc, 122, 100, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Short", NULL, NULL },
6165 { jwin_check_proc, 122, 110, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Long", NULL, NULL },
6166 // 28
6167 { jwin_frame_proc, 114, 127, 60, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6168 { jwin_text_proc, 118, 124, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Candle", NULL, NULL },
6169 { jwin_check_proc, 122, 134, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6170 { jwin_check_proc, 122, 144, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6171 // 32
6172 { jwin_frame_proc, 217, 45, 77, 138, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6173 { jwin_text_proc, 221, 42, 80, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Other", NULL, NULL },
6174 { jwin_check_proc, 225, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Bait", NULL, NULL },
6175 { jwin_check_proc, 225, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Letter", NULL, NULL },
6176 { jwin_check_proc, 225, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wand", NULL, NULL },
6177 { jwin_check_proc, 225, 82, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Lens", NULL, NULL },
6178 { jwin_check_proc, 225, 92, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Din's Fire", NULL, NULL },
6179 { jwin_check_proc, 225, 102, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Farore's Wind", NULL, NULL },
6180 { jwin_check_proc, 225, 112, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Nayru's Love", NULL, NULL },
6181 { jwin_text_proc, 225, 132, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bombs:", NULL, NULL },
6182 { jwin_edit_proc, 229, 142, 40, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
6183 { jwin_text_proc, 225, 162, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "S-Bombs:", NULL, NULL },
6184 { jwin_edit_proc, 229, 162, 40, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
6185 { jwin_check_proc, 225, 122, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Cane of Byrna", NULL, NULL },
6186 //45
6187 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6188 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6189 };*/
6190
6191
6192
6193 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6194 {
6195 go();
6196 int32_t ret=0;
6197 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
6198 comeback();
6199 return ret != 0;
6200 }
6201
6202
6203 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6204 {
6205 if(def!=modulepath)
6206 strcpy(modulepath,def);
6207
6208 if(!usefilename)
6209 {
6210 int32_t i=(int32_t)strlen(modulepath);
6211
6212 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
6213 modulepath[i--]=0;
6214 }
6215
6216 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
6217 int32_t ret=0;
6218 int32_t sel=0;
6219
6220 if(list==NULL)
6221 {
6222 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,lfont);
6223 }
6224 else
6225 {
6226 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, lfont);
6227 }
6228
6229 return ret!=0;
6230 }
6231
6232 //The Dialogue that loads a ZMOD Module File
6233 int32_t zc_load_zmod_module_file()
6234 {
6235 if ( Playing )
6236 {
6237 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6238 return -1;
6239 }
6240 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
6241 return D_CLOSE;
6242
6243 FILE *tempmodule = fopen(modulepath,"r");
6244
6245 if(tempmodule == NULL)
6246 {
6247 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6248 return -1;
6249 }
6250
6251
6252 //Set the module path:
6253 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
6254 strcpy(moduledata.module_name, modulepath);
6255 al_trace("New Module Path is: %s \n", moduledata.module_name);
6256 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
6257 zcm.init(true); //Load the module values.
6258 moduledata.refresh_title_screen = 1;
6259 // refresh_select_screen = 1;
6260 build_biic_list();
6261 return D_O_K;
6262 }
6263
6264 static DIALOG module_info_dlg[] =
6265 {
6266 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6267
6268
6269 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
6270 //1
6271 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
6272 //2
6273 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6274 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
6275 //4
6276 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6277 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6278 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
6279 //7
6280
6281 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6282 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6283 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6284 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6285 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6286 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6287 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6288 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6289 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6290
6291 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6292 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6293 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6294 };
6295
6296 void about_zcplayer_module(const char *prompt,int32_t initialval)
6297 {
6298
6299 module_info_dlg[0].dp2 = lfont;
6300 if ( moduledata.moduletitle[0] != 0 )
6301 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
6302
6303 if ( moduledata.moduleauthor[0] != 0 )
6304 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
6305
6306 if ( moduledata.moduleinfo0[0] != 0 )
6307 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
6308 if ( moduledata.moduleinfo1[0] != 0 )
6309 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
6310 if ( moduledata.moduleinfo2[0] != 0 )
6311 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
6312 if ( moduledata.moduleinfo3[0] != 0 )
6313 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
6314 if ( moduledata.moduleinfo4[0] != 0 )
6315 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
6316
6317 char module_date[255];
6318 memset(module_date, 0, sizeof(module_date));
6319 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
6320 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
6321
6322
6323
6324 char module_vers[255];
6325 memset(module_vers, 0, sizeof(module_vers));
6326 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
6327
6328
6329 //sprintf(tilecount,"%d",1);
6330
6331 char module_build[255];
6332 memset(module_build, 0, sizeof(module_build));
6333 if ( moduledata.modbeta )
6334 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
6335 else
6336 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
6337
6338 module_info_dlg[12].dp = (char*)module_date;
6339 module_info_dlg[13].dp = (char*)module_vers;
6340 module_info_dlg[14].dp = (char*)module_build;
6341
6342 if(is_large)
6343 large_dialog(module_info_dlg);
6344
6345 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
6346 jwin_center_dialog(module_info_dlg);
6347
6348
6349 }
6350
6351 int32_t onAbout_ZCP_Module()
6352 {
6353 about_zcplayer_module("About Module (.zmod)", 0);
6354 return D_O_K;
6355 }
6356
6357 //New Modules Menu for 2.55+
6358 static MENU zcmodule_menu[] =
6359 {
6360 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
6361 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
6362
6363 { NULL, NULL, NULL, 0, NULL }
6364 };
6365
6366 int32_t onToggleRecordingNewSaves()
6367 {
6368 if (zc_get_config("zeldadx", "replay_new_saves", false))
6369 {
6370 zc_set_config("zeldadx", "replay_new_saves", false);
6371 }
6372 else
6373 {
6374 zc_set_config("zeldadx", "replay_new_saves", true);
6375 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6376 NULL,NULL,"OK",NULL,13,27,lfont);
6377 }
6378 return D_O_K;
6379 }
6380
6381 int32_t onToggleSnapshotAllFrames()
6382 {
6383 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6384 return D_O_K;
6385 }
6386
6387 int32_t onStopReplayOrRecord()
6388 {
6389 if (replay_is_replaying())
6390 {
6391 replay_quit();
6392 }
6393 else if (replay_get_mode() == ReplayMode::Record)
6394 {
6395 if (!replay_get_meta_bool("test_mode"))
6396 {
6397 jwin_alert("Recording", "You cannot stop recording a save file.",
6398 NULL,NULL,"OK",NULL,13,27,lfont);
6399 return D_CLOSE;
6400 }
6401
6402 if (jwin_alert("Stop Recording",
6403 "Save replay to disk and stop recording?",
6404 "This will stop the recording.",
6405 NULL,
6406 "Yes","No",13,27,lfont) != 1)
6407 return D_CLOSE;
6408
6409 replay_save();
6410 replay_stop();
6411 }
6412 return D_O_K;
6413 }
6414
6415 static int32_t handle_on_load_replay(ReplayMode mode)
6416 {
6417 if (Playing)
6418 {
6419 if (jwin_alert("Replay - Warning!",
6420 "Loading a replay will exit the current game.",
6421 "All unsaved progress will be lost.",
6422 "Do you wish to continue?",
6423 "Yes","No",13,27,lfont) != 1)
6424 return D_CLOSE;
6425 }
6426
6427 std::string mode_string = replay_mode_to_string(mode);
6428 mode_string[0] = std::toupper(mode_string[0]);
6429
6430 std::string line_1 = "Select a replay file to play back.";
6431 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6432 std::string line_3 = "You can stop the replay and take over manually any time.";
6433 if (mode == ReplayMode::Update)
6434 {
6435 line_1 = "Select a replay file to update.";
6436 line_2 = "WARNING: be sure to back up the zplay file";
6437 line_3 = "and verify that the updated replay works as expected!";
6438 }
6439
6440 if (jwin_alert(mode_string.c_str(),
6441 line_1.c_str(),
6442 line_2.c_str(),
6443 line_3.c_str(),
6444 "OK","Nevermind",13,27,lfont) == 1)
6445 {
6446 char replay_path[2048];
6447 strcpy(replay_path, "replays/");
6448 if (jwin_file_select_ex(
6449 fmt::format("Load Replay (.{})", REPLAY_EXTENSION).c_str(),
6450 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6451 return D_CLOSE;
6452
6453 replay_quit();
6454 load_replay_file_deferred(mode, replay_path);
6455 Quit = qRESET;
6456 return D_CLOSE;
6457 }
6458 return D_O_K;
6459 }
6460
6461 int32_t onLoadReplay()
6462 {
6463 return handle_on_load_replay(ReplayMode::Replay);
6464 }
6465
6466 int32_t onLoadReplayAssert()
6467 {
6468 return handle_on_load_replay(ReplayMode::Assert);
6469 }
6470
6471 int32_t onLoadReplayUpdate()
6472 {
6473 return handle_on_load_replay(ReplayMode::Update);
6474 }
6475
6476 int32_t onSaveReplay()
6477 {
6478 if (replay_get_mode() == ReplayMode::Record)
6479 {
6480 if (!replay_get_meta_bool("test_mode"))
6481 {
6482 if (jwin_alert("Save Replay",
6483 "This will save a copy of the replay up to this point.",
6484 "The official replay file will be untouched.",
6485 "Do you wish to continue?",
6486 "Yes","No",13,27,lfont) != 1)
6487 return D_CLOSE;
6488
6489 char replay_path[2048];
6490 strcpy(replay_path, replay_get_replay_path().string().c_str());
6491 if (jwin_file_select_ex(
6492 fmt::format("Save Replay (.{})", REPLAY_EXTENSION).c_str(),
6493 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6494 return D_CLOSE;
6495
6496 if (fileexists(replay_path))
6497 {
6498 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6499 NULL,NULL,"OK",NULL,13,27,lfont);
6500 return D_CLOSE;
6501 }
6502
6503 replay_save(replay_path);
6504 }
6505 else
6506 {
6507 replay_save();
6508 }
6509 }
6510 return D_O_K;
6511 }
6512
6513 static MENU replay_menu[] =
6514 {
6515 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6516 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6517 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6518 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6519 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6520 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6521 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6522
6523 { NULL, NULL, NULL, 0, NULL }
6524 };
6525
6526 static DIALOG credits_dlg[] =
6527 {
6528 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6529 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Zelda Classic Credits", NULL, NULL },
6530 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6531 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6532 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6533 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6534 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6535 };
6536
6537 23 static ListData dmap_list(dmaplist, &font);
6538
6539 static DIALOG goto_dlg[] =
6540 {
6541 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6542 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6543 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6544 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6545 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6546 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6547 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6548 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6549 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6550 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6551 };
6552
6553 int32_t onGoTo()
6554 {
6555 bool music = false;
6556 music = music;
6557 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6558
6559 goto_dlg[0].dp2=lfont;
6560 goto_dlg[4].d2=cheat_goto_dmap;
6561 goto_dlg[6].dp=cheat_goto_screen_str;
6562
6563 clear_keybuf();
6564
6565 if(is_large)
6566 large_dialog(goto_dlg);
6567
6568 if(zc_popup_dialog(goto_dlg,4)==1)
6569 {
6570 // dmap, screen
6571 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6572 };
6573
6574 return D_O_K;
6575 }
6576
6577 int32_t onGoToComplete()
6578 {
6579 if(!Playing)
6580 {
6581 return D_O_K;
6582 }
6583
6584 system_pal();
6585 music_pause();
6586 pause_all_sfx();
6587 show_mouse(screen);
6588 onGoTo();
6589 eat_buttons();
6590
6591 zc_readrawkey(KEY_ESC);
6592
6593 show_mouse(NULL);
6594 game_pal();
6595 music_resume();
6596 resume_all_sfx();
6597 return D_O_K;
6598 }
6599
6600 int32_t onCredits()
6601 {
6602 go();
6603
6604 BITMAP *win = create_bitmap_ex(8,222,110);
6605
6606 if(!win)
6607 return D_O_K;
6608
6609 int32_t c=0;
6610 int32_t l=0;
6611 int32_t ol=-1;
6612 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6613 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6614 PALETTE tmppal;
6615
6616 rti_gui.transparency_index = 1;
6617
6618 clear_to_color(win, rti_gui.transparency_index);
6619 draw_rle_sprite(win,rle,0,0);
6620 credits_dlg[0].dp2=lfont;
6621 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6622 credits_dlg[2].dp = win;
6623
6624 set_palette_range(black_palette,0,127,false);
6625
6626 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6627
6628 BITMAP* old_screen = screen;
6629 BITMAP* gui_bmp = zc_get_gui_bmp();
6630 ASSERT(gui_bmp);
6631 clear_to_color(gui_bmp, rti_gui.transparency_index);
6632 screen = gui_bmp;
6633
6634 while(update_dialog(p))
6635 {
6636 throttleFPS();
6637 ++c;
6638 l = zc_max((c>>1)-30,0);
6639
6640 if(l > rle->h)
6641 l = c = 0;
6642
6643 if(l > rle->h - 112)
6644 l = rle->h - 112;
6645
6646 clear_bitmap(win);
6647 draw_rle_sprite(win,rle,0,0-l);
6648
6649 if(c<=64)
6650 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6651
6652 set_palette_range(tmppal,0,127,false);
6653
6654 if(l!=ol)
6655 {
6656 scare_mouse();
6657 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6658 unscare_mouse();
6659 SCRFIX();
6660 ol=l;
6661 }
6662
6663 update_hw_screen();
6664 }
6665
6666 screen = old_screen;
6667 system_pal();
6668
6669 shutdown_dialog(p);
6670 destroy_bitmap(win);
6671 //comeback();
6672
6673 rti_gui.transparency_index = 0;
6674
6675 return D_O_K;
6676 }
6677
6678 const char *midilist(int32_t index, int32_t *list_size)
6679 {
6680 if(index<0)
6681 {
6682 *list_size=0;
6683
6684 for(int32_t i=0; i<MAXMIDIS; i++)
6685 if(tunes[i].data)
6686 ++(*list_size);
6687
6688 return NULL;
6689 }
6690
6691 int32_t i=0,m=0;
6692
6693 while(m<=index && i<=MAXMIDIS)
6694 {
6695 if(tunes[i].data)
6696 ++m;
6697
6698 ++i;
6699 }
6700
6701 --i;
6702
6703 if(i==MAXMIDIS && m<index)
6704 return "(null)";
6705
6706 return tunes[i].title;
6707 }
6708
6709 /* ------- MIDI info stuff -------- */
6710
6711 char *text;
6712 midi_info *zmi;
6713 bool dialog_running;
6714 bool listening;
6715
6716 void get_info(int32_t index);
6717
6718 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6719 {
6720 int32_t d2 = d->d2;
6721 int32_t ret = jwin_droplist_proc(msg,d,c);
6722
6723 if(d2!=d->d2)
6724 {
6725 get_info(d->d2);
6726 }
6727
6728 return ret;
6729 }
6730
6731 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6732 {
6733 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6734
6735 int32_t ret = jwin_button_proc(msg,d,c);
6736
6737 if(ret == D_CLOSE)
6738 {
6739 // get current midi index
6740 int32_t index = (d+(d->d1))->d2;
6741 int32_t i=0, m=0;
6742
6743 while(m<=index && i<=MAXMIDIS)
6744 {
6745 if(tunes[i].data)
6746 ++m;
6747
6748 ++i;
6749 }
6750
6751 --i;
6752 jukebox(i);
6753 listening = true;
6754 ret = D_O_K;
6755 }
6756
6757 return ret;
6758 }
6759
6760 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6761 {
6762 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6763
6764 int32_t ret = jwin_button_proc(msg,d,c);
6765
6766 if(ret == D_CLOSE)
6767 {
6768 // get current midi index
6769 int32_t index = (d+(d->d1))->d2;
6770 int32_t i=0, m=0;
6771
6772 while(m<=index && i<=MAXMIDIS)
6773 {
6774 if(tunes[i].data)
6775 ++m;
6776
6777 ++i;
6778 }
6779
6780 --i;
6781
6782 // get file name
6783
6784 int32_t sel=0;
6785 //struct ffblk f;
6786 char title[40] = "Save MIDI: ";
6787 char fname[2048];
6788 memset(fname,0,2048);
6789 static EXT_LIST list[] =
6790 {
6791 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6792 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6793 { NULL, NULL }
6794 };
6795
6796 strcpy(title+11, tunes[i].title);
6797 title[39] = '\0';
6798
6799 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, lfont)==0)
6800 goto done;
6801
6802 if(exists(fname))
6803 {
6804 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',lfont)==2)
6805 goto done;
6806 }
6807
6808 // save midi i
6809
6810 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6811 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,lfont);
6812
6813 done:
6814 chop_path(fname);
6815 ret = D_REDRAW;
6816 }
6817
6818 return ret;
6819 }
6820
6821 23 static ListData midi_list(midilist, &font);
6822
6823 static DIALOG midi_dlg[] =
6824 {
6825 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6826 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6827 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6828 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6829 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6830 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6831 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6832 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6833 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6834 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6835 };
6836
6837 void get_info(int32_t index)
6838 {
6839 int32_t i=0, m=0;
6840
6841 while(m<=index && i<=MAXMIDIS)
6842 {
6843 if(tunes[i].data)
6844 ++m;
6845
6846 ++i;
6847 }
6848
6849 --i;
6850
6851 if(i==MAXMIDIS && m<index)
6852 strcpy(text,"(null)");
6853 else
6854 {
6855 get_midi_info((MIDI*)tunes[i].data,zmi);
6856 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6857 }
6858
6859 midi_dlg[0].dp2=lfont;
6860 midi_dlg[3].dp = text;
6861 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6862 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6863
6864 if(dialog_running)
6865 {
6866 scare_mouse();
6867 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6868 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6869 unscare_mouse();
6870 }
6871 }
6872
6873 int32_t onMIDICredits()
6874 {
6875 text = (char*)malloc(4096);
6876 zmi = (midi_info*)malloc(sizeof(midi_info));
6877
6878 if(!text || !zmi)
6879 {
6880 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,lfont);
6881 return D_O_K;
6882 }
6883
6884 bool do_pause_midi = midi_pos >= 0 && currmidi;
6885 auto restore_midi = currmidi;
6886 if(do_pause_midi)
6887 {
6888 paused_midi_pos = midi_pos;
6889 stop_midi();
6890 midi_paused=true;
6891 midi_suspended = midissuspHALTED;
6892 }
6893
6894 midi_dlg[0].dp2=lfont;
6895 midi_dlg[2].d1 = 0;
6896 midi_dlg[2].d2 = 0;
6897 midi_dlg[4].flags = D_EXIT;
6898 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6899
6900 listening = false;
6901 dialog_running=false;
6902 get_info(0);
6903
6904 dialog_running=true;
6905
6906 if(is_large)
6907 large_dialog(midi_dlg);
6908
6909 zc_popup_dialog(midi_dlg,0);
6910 dialog_running=false;
6911
6912 if(listening)
6913 music_stop();
6914
6915 if(do_pause_midi)
6916 {
6917 midi_suspended = midissuspRESUME;
6918 currmidi = restore_midi;
6919 midi_pos = paused_midi_pos;
6920 }
6921
6922 if(text) free(text);
6923 if(zmi) free(zmi);
6924 return D_O_K;
6925 }
6926
6927 int32_t onAbout()
6928 {
6929 char buf1[80]={0};
6930 std::ostringstream oss;
6931 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
6932 oss << buf1 << '\n';
6933 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
6934 oss << buf1 << '\n';
6935 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6936 oss << buf1 << '\n';
6937 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6938 oss << buf1 << '\n';
6939 sprintf(buf1, "Tag: %s", getReleaseTag());
6940 oss << buf1 << '\n';
6941
6942 InfoDialog("About ZC", oss.str()).show();
6943 return D_O_K;
6944 }
6945
6946 int32_t onQuest()
6947 {
6948 char fname[100];
6949 strcpy(fname, get_filename(qstpath));
6950 quest_dlg[0].dp2=lfont;
6951 quest_dlg[1].dp = fname;
6952
6953 if(QHeader.quest_number==0)
6954 sprintf(str_a,"Custom");
6955 else
6956 sprintf(str_a,"%d",QHeader.quest_number);
6957
6958 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6959
6960 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6961 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6962
6963 if(is_large)
6964 large_dialog(quest_dlg);
6965
6966 zc_popup_dialog(quest_dlg, 0);
6967 return D_O_K;
6968 }
6969
6970 void call_vidmode_dlg();
6971 int32_t onVidMode()
6972 {
6973 call_vidmode_dlg();
6974 return D_O_K;
6975 }
6976
6977 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6978 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6979 //Added an extra statement, so that if the key is cleared to 0, the cleared
6980 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6981
6982 void load_ukeys(int32_t* arr)
6983 {
6984 arr[ukey_a] = Akey;
6985 arr[ukey_b] = Bkey;
6986 arr[ukey_s] = Skey;
6987 arr[ukey_l] = Lkey;
6988 arr[ukey_r] = Rkey;
6989 arr[ukey_p] = Pkey;
6990 arr[ukey_ex1] = Exkey1;
6991 arr[ukey_ex2] = Exkey2;
6992 arr[ukey_ex3] = Exkey3;
6993 arr[ukey_ex4] = Exkey4;
6994 arr[ukey_du] = DUkey;
6995 arr[ukey_dd] = DDkey;
6996 arr[ukey_dl] = DLkey;
6997 arr[ukey_dr] = DRkey;
6998 arr[ukey_mod1a] = cheat_modifier_keys[0];
6999 arr[ukey_mod1b] = cheat_modifier_keys[1];
7000 arr[ukey_mod2a] = cheat_modifier_keys[2];
7001 arr[ukey_mod2b] = cheat_modifier_keys[3];
7002 };
7003
7004 static const char* ukey_names[] = {
7005 "A", "B", "Start", "L", "R", "Map",
7006 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
7007 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
7008 "Cheat Mod R1", "Cheat Mod R2",
7009 };
7010 std::string get_ukey_name(int32_t k)
7011 {
7012 if (k < num_ukey) return ukey_names[k];
7013 return "";
7014 }
7015
7016 int32_t onKeyboard()
7017 {
7018 int32_t a = Akey;
7019 int32_t b = Bkey;
7020 int32_t s = Skey;
7021 int32_t l = Lkey;
7022 int32_t r = Rkey;
7023 int32_t p = Pkey;
7024 int32_t ex1 = Exkey1;
7025 int32_t ex2 = Exkey2;
7026 int32_t ex3 = Exkey3;
7027 int32_t ex4 = Exkey4;
7028 int32_t du = DUkey;
7029 int32_t dd = DDkey;
7030 int32_t dl = DLkey;
7031 int32_t dr = DRkey;
7032 int32_t mod1a = cheat_modifier_keys[0];
7033 int32_t mod1b = cheat_modifier_keys[1];
7034 int32_t mod2a = cheat_modifier_keys[2];
7035 int32_t mod2b = cheat_modifier_keys[3];
7036 bool done=false;
7037 int32_t ret;
7038
7039 keyboard_control_dlg[0].dp2=lfont;
7040
7041 if(is_large)
7042 large_dialog(keyboard_control_dlg);
7043
7044 while(!done)
7045 {
7046 ret = zc_popup_dialog(keyboard_control_dlg,3);
7047
7048 if(ret==3) // OK
7049 {
7050 int32_t ukeys[num_ukey];
7051 load_ukeys(ukeys);
7052 std::vector<std::string> uniqueError;
7053 for(int32_t q = 0; q < num_ukey; ++q)
7054 {
7055 for(int32_t p = q+1; p < num_ukey; ++p)
7056 {
7057 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
7058 {
7059 char buf[64];
7060 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
7061 std::string str(buf);
7062 uniqueError.push_back(str);
7063 }
7064 }
7065 }
7066 if(uniqueError.size() == 0)
7067 {
7068 done = true;
7069 save_control_configs(true);
7070 }
7071 else
7072 {
7073 box_start(1, "Duplicate Keys", lfont, sfont, false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
7074 box_out("Cannot have duplicate keybinds!"); box_eol();
7075 for(std::vector<std::string>::iterator it = uniqueError.begin();
7076 it != uniqueError.end(); ++it)
7077 {
7078 box_out((*it).c_str()); box_eol();
7079 }
7080 box_end(true);
7081 }
7082 /* Old uniqueness check
7083 std::map<int32_t,bool> *keyhash = new std::map<int32_t,bool>();
7084 bool unique = true;
7085 addToHash(A,unique,keyhash);
7086 addToHash(B,unique,keyhash);
7087 addToHash(S,unique,keyhash);
7088 addToHash(L,unique,keyhash);
7089 addToHash(R,unique,keyhash);
7090 addToHash(P,unique,keyhash);
7091 addToHash(DU,unique,keyhash);
7092 addToHash(DD,unique,keyhash);
7093 addToHash(DL,unique,keyhash);
7094 addToHash(DR,unique,keyhash);
7095
7096 if(keyhash->find(Exkey1) == keyhash->end())
7097 {
7098 (*keyhash)[Exkey1]=true;
7099 }
7100 else
7101 {
7102 if ( Exkey1 != 0 ) unique = false;
7103 }
7104
7105 if(keyhash->find(Exkey2) == keyhash->end())
7106 {
7107 (*keyhash)[Exkey2]=true;
7108 }
7109 else
7110 {
7111 if ( Exkey2 != 0 ) unique = false;
7112 }
7113
7114 if(keyhash->find(Exkey3) == keyhash->end())
7115 {
7116 (*keyhash)[Exkey3]=true;
7117 }
7118 else
7119 {
7120 if ( Exkey3 != 0 ) unique = false;
7121 }
7122
7123 if(keyhash->find(Exkey4) == keyhash->end())
7124 {
7125 (*keyhash)[Exkey4]=true;
7126 }
7127 else
7128 {
7129 if ( Exkey4 != 0 )unique = false;
7130 }
7131 //modifier keys
7132 if(keyhash->find(cheat_modifier_keys[0]) == keyhash->end())
7133 {
7134 (*keyhash)[cheat_modifier_keys[0]]=true;
7135 }
7136 else
7137 {
7138 if ( cheat_modifier_keys[0] != 0 ) unique = false;
7139 }
7140 if(keyhash->find(cheat_modifier_keys[1]) == keyhash->end())
7141 {
7142 (*keyhash)[cheat_modifier_keys[1]]=true;
7143 }
7144 else
7145 {
7146 if ( cheat_modifier_keys[1] != 0 ) unique = false;
7147 }
7148 if(keyhash->find(cheat_modifier_keys[2]) == keyhash->end())
7149 {
7150 (*keyhash)[cheat_modifier_keys[2]]=true;
7151 }
7152 else
7153 {
7154 if ( cheat_modifier_keys[2] != 0 ) unique = false;
7155 }
7156 if(keyhash->find(cheat_modifier_keys[3]) == keyhash->end())
7157 {
7158 (*keyhash)[cheat_modifier_keys[3]]=true;
7159 }
7160 else
7161 {
7162 if ( cheat_modifier_keys[3] != 0 ) unique = false;
7163 }
7164
7165 delete keyhash;
7166
7167 if(unique)
7168 done=true;
7169 else
7170 jwin_alert("Error", "Key bindings must be unique!", "", "", "OK",NULL,'o',0,lfont);
7171 */
7172 }
7173 else // Cancel
7174 {
7175 Akey = a;
7176 Bkey = b;
7177 Skey = s;
7178 Lkey = l;
7179 Rkey = r;
7180 Pkey = p;
7181 Exkey1 = ex1;
7182 Exkey2 = ex2;
7183 Exkey3 = ex3;
7184 Exkey4 = ex4;
7185 DUkey = du;
7186 DDkey = dd;
7187 DLkey = dl;
7188 DRkey = dr;
7189 cheat_modifier_keys[0] = mod1a;
7190 cheat_modifier_keys[1] = mod1b;
7191 cheat_modifier_keys[2] = mod2a;
7192 cheat_modifier_keys[3] = mod2b;
7193
7194 done=true;
7195 }
7196
7197 rest(1);
7198 }
7199
7200 return D_O_K;
7201 }
7202
7203 int32_t onGamepad()
7204 {
7205 int32_t a = Abtn;
7206 int32_t b = Bbtn;
7207 int32_t s = Sbtn;
7208 int32_t l = Lbtn;
7209 int32_t r = Rbtn;
7210 int32_t m = Mbtn;
7211 int32_t p = Pbtn;
7212 int32_t ex1 = Exbtn1;
7213 int32_t ex2 = Exbtn2;
7214 int32_t ex3 = Exbtn3;
7215 int32_t ex4 = Exbtn4;
7216 int32_t up = DUbtn;
7217 int32_t down = DDbtn;
7218 int32_t left = DLbtn;
7219 int32_t right = DRbtn;
7220
7221 gamepad_dlg[0].dp2=lfont;
7222 if(analog_movement)
7223 gamepad_dlg[56].flags|=D_SELECTED;
7224 else
7225 gamepad_dlg[56].flags&=~D_SELECTED;
7226
7227 if(is_large)
7228 large_dialog(gamepad_dlg);
7229
7230 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
7231
7232 if(ret == 4) //OK
7233 {
7234 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
7235 save_control_configs(false);
7236 }
7237 else //Cancel
7238 {
7239 Abtn = a;
7240 Bbtn = b;
7241 Sbtn = s;
7242 Lbtn = l;
7243 Rbtn = r;
7244 Mbtn = m;
7245 Pbtn = p;
7246 Exbtn1 = ex1;
7247 Exbtn2 = ex2;
7248 Exbtn3 = ex3;
7249 Exbtn4 = ex4;
7250 DUbtn = up;
7251 DDbtn = down;
7252 DLbtn = left;
7253 DRbtn = right;
7254 }
7255
7256 return D_O_K;
7257 }
7258
7259 int32_t onSound()
7260 {
7261 if ( FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME )
7262 {
7263 master_volume(-1,((int32_t)FFCore.usr_midi_volume));
7264 }
7265 if ( FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME )
7266 {
7267 master_volume((int32_t)(FFCore.usr_digi_volume),1);
7268 }
7269 if ( FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME )
7270 {
7271 emusic_volume = (int32_t)FFCore.usr_music_volume;
7272 }
7273 if ( FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME )
7274 {
7275 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
7276 }
7277 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
7278 {
7279 pan_style = (int32_t)FFCore.usr_panstyle;
7280 }
7281
7282 int32_t m = midi_volume;
7283 int32_t d = digi_volume;
7284 int32_t e = emusic_volume;
7285 int32_t b = zcmusic_bufsz;
7286 int32_t s = sfx_volume;
7287 int32_t p = pan_style;
7288 pan_style = vbound(pan_style,0,3);
7289
7290 sound_dlg[0].dp2=lfont;
7291
7292 if(is_large)
7293 large_dialog(sound_dlg);
7294
7295 midi_dp[1] = sound_dlg[6].x;
7296 midi_dp[2] = sound_dlg[6].y;
7297 digi_dp[1] = sound_dlg[7].x;
7298 digi_dp[2] = sound_dlg[7].y;
7299 emus_dp[1] = sound_dlg[8].x;
7300 emus_dp[2] = sound_dlg[8].y;
7301 buf_dp[1] = sound_dlg[9].x;
7302 buf_dp[2] = sound_dlg[9].y;
7303 sfx_dp[1] = sound_dlg[10].x;
7304 sfx_dp[2] = sound_dlg[10].y;
7305 pan_dp[1] = sound_dlg[11].x;
7306 pan_dp[2] = sound_dlg[11].y;
7307 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
7308 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
7309 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
7310 sound_dlg[18].d2 = zcmusic_bufsz;
7311 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
7312 sound_dlg[20].d2 = pan_style;
7313
7314 int32_t ret = zc_popup_dialog(sound_dlg,1);
7315
7316 if(ret==2)
7317 {
7318 master_volume(digi_volume,midi_volume);
7319
7320 for(int32_t i=0; i<WAV_COUNT; ++i)
7321 {
7322 //allegro assertion fails when passing in -1 as voice -DD
7323 if(sfx_voice[i] > 0)
7324 voice_set_volume(sfx_voice[i], sfx_volume);
7325 }
7326 zc_set_config(sfx_sect,"digi",digi_volume);
7327 zc_set_config(sfx_sect,"midi",midi_volume);
7328 zc_set_config(sfx_sect,"sfx",sfx_volume);
7329 zc_set_config(sfx_sect,"emusic",emusic_volume);
7330 zc_set_config(sfx_sect,"pan",pan_style);
7331 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
7332 }
7333 else
7334 {
7335 midi_volume = m;
7336 digi_volume = d;
7337 emusic_volume = e;
7338 zcmusic_bufsz = b;
7339 sfx_volume = s;
7340 pan_style = p;
7341 }
7342
7343 return D_O_K;
7344 }
7345
7346 int32_t queding(char const* s1, char const* s2, char const* s3)
7347 {
7348 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',lfont);
7349 }
7350
7351 int32_t onQuit()
7352 {
7353 if(Playing)
7354 {
7355 int32_t ret=0;
7356
7357 if(get_bit(quest_rules, qr_NOCONTINUE))
7358 {
7359 if(standalone_mode)
7360 {
7361 ret=queding("End current game?",
7362 "The continue screen is disabled; the game",
7363 "will be reloaded from the last save.");
7364 }
7365 else
7366 {
7367 ret=queding("End current game?",
7368 "The continue screen is disabled. You will",
7369 "be returned to the file select screen.");
7370 }
7371 }
7372 else
7373 ret=queding("End current game?",NULL,NULL);
7374
7375 if(ret==1)
7376 {
7377 disableClickToFreeze=false;
7378 Quit=qQUIT;
7379
7380 // Trying to evade a door repair charge?
7381 if(repaircharge)
7382 {
7383 game->change_drupy(-repaircharge);
7384 repaircharge=0;
7385 }
7386
7387 return D_CLOSE;
7388 }
7389 }
7390
7391 return D_O_K;
7392 }
7393
7394 int32_t onTryQuitMenu()
7395 {
7396 return onTryQuit(true);
7397 }
7398
7399 int32_t onTryQuit(bool inMenu)
7400 {
7401 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7402 {
7403 if(get_bit(quest_rules,qr_OLD_F6))
7404 {
7405 if(inMenu) onQuit();
7406 else /*if(!get_bit(quest_rules, qr_NOCONTINUE))*/ f_Quit(qQUIT);
7407 }
7408 else
7409 {
7410 disableClickToFreeze=false;
7411 GameFlags |= GAMEFLAG_TRYQUIT;
7412 }
7413 return D_CLOSE;
7414 }
7415
7416 return D_O_K;
7417 }
7418
7419 int32_t onReset()
7420 {
7421 if(queding(" Reset system? ",NULL,NULL)==1)
7422 {
7423 disableClickToFreeze=false;
7424 Quit=qRESET;
7425 replay_quit();
7426 return D_CLOSE;
7427 }
7428
7429 return D_O_K;
7430 }
7431
7432 int32_t onExit()
7433 {
7434 if(queding(" Quit Zelda Classic? ",NULL,NULL)==1)
7435 {
7436 Quit=qEXIT;
7437 return D_CLOSE;
7438 }
7439
7440 return D_O_K;
7441 }
7442
7443 int32_t onTitle_NES()
7444 {
7445 title_version=0;
7446 zc_set_config(cfg_sect,"title",title_version);
7447 return D_O_K;
7448 }
7449 int32_t onTitle_DX()
7450 {
7451 title_version=1;
7452 zc_set_config(cfg_sect,"title",title_version);
7453 return D_O_K;
7454 }
7455 int32_t onTitle_25()
7456 {
7457 title_version=2;
7458 zc_set_config(cfg_sect,"title",title_version);
7459 return D_O_K;
7460 }
7461
7462 int32_t onDebug()
7463 {
7464 if(debug_enabled)
7465 set_debug(!get_debug());
7466 return D_O_K;
7467 }
7468
7469 int32_t onHeartBeep()
7470 {
7471 heart_beep=!heart_beep;
7472 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7473 return D_O_K;
7474 }
7475
7476 int32_t onSaveIndicator()
7477 {
7478 use_save_indicator=!use_save_indicator;
7479 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7480 return D_O_K;
7481 }
7482
7483 int32_t onEpilepsy()
7484 {
7485 if(jwin_alert3(
7486 "Epilepsy Flash Reduction",
7487 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7488 "Disabling this will restore standard flash and wavy behaviour.",
7489 "Proceed?",
7490 "&Yes",
7491 "&No",
7492 NULL,
7493 'y',
7494 'n',
7495 0,
7496 lfont) == 1)
7497 {
7498 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7499 zc_set_config("zeldadx","checked_epilepsy",1);
7500 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7501 }
7502 return D_O_K;
7503 }
7504
7505 int32_t onTriforce()
7506 {
7507 for(int32_t i=0; i<MAXINITTABS; ++i)
7508 {
7509 init_tabs[i].flags&=~D_SELECTED;
7510 }
7511
7512 init_tabs[3].flags=D_SELECTED;
7513 return onCheatConsole();
7514 /*triforce_dlg[0].dp2=lfont;
7515 for(int32_t i=1; i<=8; i++)
7516 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7517
7518 if(zc_popup_dialog (triforce_dlg,-1)==9)
7519 {
7520 for(int32_t i=1; i<=8; i++)
7521 {
7522 game->lvlitems[i] &= ~liTRIFORCE;
7523 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7524 }
7525 }
7526 return D_O_K;*/
7527 }
7528
7529 bool rc = false;
7530 /*
7531 int32_t onEquipment()
7532 {
7533 for (int32_t i=0; i<MAXINITTABS; ++i)
7534 {
7535 init_tabs[i].flags&=~D_SELECTED;
7536 }
7537 init_tabs[0].flags=D_SELECTED;
7538 return onCheatConsole();
7539 }
7540 */
7541
7542 int32_t onItems()
7543 {
7544 for(int32_t i=0; i<MAXINITTABS; ++i)
7545 {
7546 init_tabs[i].flags&=~D_SELECTED;
7547 }
7548
7549 init_tabs[1].flags=D_SELECTED;
7550 return onCheatConsole();
7551 }
7552
7553 static DIALOG getnum_dlg[] =
7554 {
7555 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7556 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7557 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7558 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7559 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7560 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7561 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7562 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7563 };
7564
7565 int32_t getnumber(const char *prompt,int32_t initialval)
7566 {
7567 char buf[20];
7568 sprintf(buf,"%d",initialval);
7569 getnum_dlg[0].dp=(void *)prompt;
7570 getnum_dlg[0].dp2=lfont;
7571 getnum_dlg[2].dp=buf;
7572
7573 if(is_large)
7574 large_dialog(getnum_dlg);
7575
7576 if(zc_popup_dialog(getnum_dlg,2)==3)
7577 return atoi(buf);
7578
7579 return initialval;
7580 }
7581
7582 int32_t onLife()
7583 {
7584 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7585 cheats_enqueue(Cheat::Life, value);
7586 return D_O_K;
7587 }
7588
7589 int32_t onHeartC()
7590 {
7591 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7592 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7593 cheats_enqueue(Cheat::MaxLife, max_life);
7594 cheats_enqueue(Cheat::Life, life);
7595 return D_O_K;
7596 }
7597
7598 int32_t onMagicC()
7599 {
7600 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7601 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7602 cheats_enqueue(Cheat::MaxMagic, max_magic);
7603 cheats_enqueue(Cheat::Magic, magic);
7604 return D_O_K;
7605 }
7606
7607 int32_t onRupies()
7608 {
7609 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7610 cheats_enqueue(Cheat::Rupies, value);
7611 return D_O_K;
7612 }
7613
7614 int32_t onMaxBombs()
7615 {
7616 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7617 cheats_enqueue(Cheat::MaxBombs, value);
7618 cheats_enqueue(Cheat::Bombs, value);
7619 return D_O_K;
7620 }
7621
7622 int32_t onRefillLife()
7623 {
7624 cheats_enqueue(Cheat::Life, game->get_maxlife());
7625 return D_O_K;
7626 }
7627 int32_t onRefillMagic()
7628 {
7629 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7630 return D_O_K;
7631 }
7632 int32_t onClock()
7633 {
7634 cheats_enqueue(Cheat::Clock);
7635 return D_O_K;
7636 }
7637
7638 int32_t onQstPath()
7639 {
7640 char path[2048];
7641
7642 chop_path(qstdir);
7643 strcpy(path,qstdir);
7644
7645 go();
7646
7647 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, lfont))
7648 {
7649 chop_path(path);
7650 fix_filename_case(path);
7651 fix_filename_slashes(path);
7652 strcpy(qstdir,path);
7653 strcpy(qstpath,qstdir);
7654 }
7655
7656 comeback();
7657 return D_O_K;
7658 }
7659
7660 #include "dialog/cheat_dialog.h"
7661 int32_t onCheat()
7662 {
7663 call_setcheat_dialog();
7664 game->set_cheat(maxcheat);
7665 if(cheat) game->did_cheat(true);
7666 return D_O_K;
7667 }
7668
7669 int32_t onCheatRupies()
7670 {
7671 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7672 return D_O_K;
7673 }
7674
7675 int32_t onCheatArrows()
7676 {
7677 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7678 return D_O_K;
7679 }
7680
7681 int32_t onCheatBombs()
7682 {
7683 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7684 return D_O_K;
7685 }
7686
7687 // *** screen saver
7688
7689 4391070 int32_t after_time()
7690 {
7691
1/2
✓ Branch 0 taken 4391070 times.
✗ Branch 1 not taken.
4391070 if(ss_enable == 0)
7692 return INT_MAX;
7693
7694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4391070 times.
4391070 if(ss_after <= 0)
7695 return 5 * 60;
7696
7697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4391070 times.
4391070 if(ss_after <= 3)
7698 return ss_after * 15 * 60;
7699
7700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4391070 times.
4391070 if(ss_after <= 13)
7701 return (ss_after - 3) * 60 * 60;
7702
7703 4391070 return MAX_IDLE + 1;
7704 4391070 }
7705
7706 static const char *after_str[15] =
7707 {
7708 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7709 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7710 "Never"
7711 };
7712
7713 const char *after_list(int32_t index, int32_t *list_size)
7714 {
7715 if(index < 0)
7716 {
7717 *list_size = 15;
7718 return NULL;
7719 }
7720
7721 return after_str[index];
7722 }
7723
7724 23 static ListData after__list(after_list, &font);
7725
7726 static DIALOG scrsaver_dlg[] =
7727 {
7728 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7729 23 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7730 23 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7731 23 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7732 23 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7733 23 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7734 23 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7735 23 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7736 23 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7737 23 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7738 23 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7739 23 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7740 23 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7741 23 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7742 };
7743
7744 int32_t onScreenSaver()
7745 {
7746 scrsaver_dlg[0].dp2=lfont;
7747 int32_t oldcfgs[3];
7748 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7749 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7750 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7751
7752 if(is_large)
7753 large_dialog(scrsaver_dlg);
7754
7755 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7756
7757 if(ret == 8 || ret == 9)
7758 {
7759 ss_after = scrsaver_dlg[5].d1;
7760 ss_speed = scrsaver_dlg[6].d2;
7761 ss_density = scrsaver_dlg[7].d2;
7762 if(oldcfgs[0] != ss_after)
7763 zc_set_config(cfg_sect,"ss_after",ss_after);
7764 if(oldcfgs[1] != ss_speed)
7765 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7766 if(oldcfgs[2] != ss_density)
7767 zc_set_config(cfg_sect,"ss_density",ss_density);
7768 }
7769
7770 if(ret == 9)
7771 // preview Screen Saver
7772 {
7773 clear_keybuf();
7774 scare_mouse();
7775 Matrix(ss_speed, ss_density, 30);
7776 system_pal();
7777 unscare_mouse();
7778 }
7779
7780 return D_O_K;
7781 }
7782
7783 /***** Menus *****/
7784
7785 static MENU game_menu[] =
7786 {
7787 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7788 { (char *)"", NULL, NULL, 0, NULL },
7789 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7790 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7791 { (char *)"", NULL, NULL, 0, NULL },
7792 #ifdef __EMSCRIPTEN__
7793 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7794 #elif defined(ALLEGRO_MACOSX)
7795 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7796 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7797 #else
7798 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7799 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7800 #endif
7801 { NULL, NULL, NULL, 0, NULL }
7802 };
7803
7804 static MENU title_menu[] =
7805 {
7806 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7807 { (char *)"&Zelda Classic", onTitle_DX, NULL, 0, NULL },
7808 { (char *)"Zelda Classic &2.50", onTitle_25, NULL, 0, NULL },
7809 { NULL, NULL, NULL, 0, NULL }
7810 };
7811
7812 static MENU snapshot_format_menu[] =
7813 {
7814 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7815 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7816 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7817 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7818 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7819 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7820 { NULL, NULL, NULL, 0, NULL }
7821 };
7822
7823 static MENU controls_menu[] =
7824 {
7825 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7826 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7827 { NULL, NULL, NULL, 0, NULL }
7828 };
7829
7830 static MENU name_entry_mode_menu[] =
7831 {
7832 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7833 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7834 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7835 { NULL, NULL, NULL, 0, NULL }
7836 };
7837
7838 static void set_controls_menu_active()
7839 {
7840
7841 }
7842
7843 static MENU settings_menu[] =
7844 {
7845 { (char *)"&Sound...", onSound, NULL, 0, NULL },
7846 { (char *)"C&ontrols", NULL, controls_menu, 0, NULL },
7847 { (char *)"&Title Screen", NULL, title_menu, 0, NULL },
7848 { (char *)"Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7849 { (char *)"", NULL, NULL, 0, NULL },
7850 { (char *)"&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7851 { (char *)"Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7852 { (char *)"Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7853 { (char *)"Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7854 { (char *)"Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7855 { (char *)"Autosave Window Size Changes", onSaveDragResize, NULL, 0, NULL },
7856 { (char *)"Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7857 { (char *)"Window Position Saving", onWinPosSave, NULL, 0, NULL },
7858 { (char *)"Volume &Keys", onVolKeys, NULL, 0, NULL },
7859 { (char *)"Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7860 { (char *)"Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7861 { (char *)"Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7862 { (char *)"S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7863 { (char *)"", NULL, NULL, 0, NULL },
7864 { (char *)"Debu&g", onDebug, NULL, 0, NULL },
7865 { (char *)"", NULL, NULL, 0, NULL },
7866 { NULL, NULL, NULL, 0, NULL }
7867 };
7868
7869
7870 static MENU misc_menu[] =
7871 {
7872 { (char *)"&About...", onAbout, NULL, 0, NULL },
7873 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7874 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7875 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7876 { (char *)"", NULL, NULL, 0, NULL },
7877 //5
7878 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7879 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7880 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7881 { (char *)"", NULL, NULL, 0, NULL },
7882 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7883 //10
7884 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7885 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7886 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7887 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7888 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7889 //15
7890 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7891 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7892 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7893
7894 { NULL, NULL, NULL, 0, NULL }
7895 };
7896
7897 static MENU refill_menu[] =
7898 {
7899 { (char *)"&Life\t*, H", onRefillLife, NULL, 0, NULL },
7900 { (char *)"&Magic\t/, M", onRefillMagic, NULL, 0, NULL },
7901 { (char *)"&Bombs\tB", onCheatBombs, NULL, 0, NULL },
7902 { (char *)"&Rupees\tR", onCheatRupies, NULL, 0, NULL },
7903 { (char *)"&Arrows\tA", onCheatArrows, NULL, 0, NULL },
7904 { NULL, NULL, NULL, 0, NULL }
7905 };
7906
7907 static MENU show_menu[] =
7908 {
7909 { (char *)"Combos\t0", onShowLayer0, NULL, 0, NULL },
7910 { (char *)"Layer 1\t1", onShowLayer1, NULL, 0, NULL },
7911 { (char *)"Layer 2\t2", onShowLayer2, NULL, 0, NULL },
7912 { (char *)"Layer 3\t3", onShowLayer3, NULL, 0, NULL },
7913 { (char *)"Layer 4\t4", onShowLayer4, NULL, 0, NULL },
7914 { (char *)"Layer 5\t5", onShowLayer5, NULL, 0, NULL },
7915 { (char *)"Layer 6\t6", onShowLayer6, NULL, 0, NULL },
7916 { (char *)"Overhead Combos\tO", onShowLayerO, NULL, 0, NULL },
7917 { (char *)"Push Blocks\tP", onShowLayerP, NULL, 0, NULL },
7918 { (char *)"Freeform Combos\t7", onShowLayerF, NULL, 0, NULL },
7919 { (char *)"Sprites\t8", onShowLayerS, NULL, 0, NULL },
7920 { (char *)"", NULL, NULL, 0, NULL },
7921 { (char *)"Walkability\tW", onShowLayerW, NULL, 0, NULL },
7922 { (char *)"Current FFC Scripts\tF", onShowFFScripts, NULL, 0, NULL },
7923 { (char *)"Hitboxes\tC", onShowHitboxes, NULL, 0, NULL },
7924 { (char *)"Effects\tE", onShowLayerE, NULL, 0, NULL },
7925 { NULL, NULL, NULL, 0, NULL }
7926 };
7927
7928 static MENU cheat_menu[] =
7929 {
7930 { (char *)"S&et Cheat", onCheat, NULL, 0, NULL },
7931 { (char *)"", NULL, NULL, 0, NULL },
7932 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7933 { (char *)"", NULL, NULL, 0, NULL },
7934 { (char *)"&Clock\tI", onClock, NULL, 0, NULL },
7935 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7936 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7937 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7938 { (char *)"", NULL, NULL, 0, NULL },
7939 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7940 { (char *)"", NULL, NULL, 0, NULL },
7941 { (char *)"Walk Through &Walls\tF11", onNoWalls, NULL, 0, NULL },
7942 { (char *)"Player Ignores Side&view\tV", onIgnoreSideview, NULL, 0, NULL },
7943 { (char *)"&Quick Movement\tQ", onGoFast, NULL, 0, NULL },
7944 { (char *)"&Kill All Enemies\tK", onKillCheat, NULL, 0, NULL },
7945 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7946 { (char *)"Toggle Light\tL", onLightSwitch, NULL, 0, NULL },
7947 { (char *)"&Goto Location...\tG", onGoTo, NULL, 0, NULL },
7948 { NULL, NULL, NULL, 0, NULL }
7949 };
7950
7951 static MENU fixes_menu[] =
7952 {
7953 { (char *)"Windows MIDI Patch", onMIDIPatch, NULL, 0, NULL },
7954 { NULL, NULL, NULL, 0, NULL }
7955 };
7956
7957 #if DEVLEVEL > 0
7958 int32_t devLogging();
7959 int32_t devDebug();
7960 int32_t devTimestmp();
7961 #if DEVLEVEL > 1
7962 int32_t setCheat();
7963 #endif //DEVLEVEL > 1
7964 enum
7965 {
7966 dv_log,
7967 // dv_dbg,
7968 dv_tmpstmp,
7969 #if DEVLEVEL > 1
7970 dv_nil,
7971 dv_setcheat,
7972 #endif //DEVLEVEL > 1
7973 dv_max
7974 };
7975 static MENU dev_menu[] =
7976 {
7977 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7978 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7979 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7980 #if DEVLEVEL > 1
7981 { (char *)"", NULL, NULL, 0, NULL },
7982 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7983 #endif //DEVLEVEL > 1
7984 { NULL, NULL, NULL, 0, NULL }
7985 };
7986 int32_t devLogging()
7987 {
7988 dev_logging = !dev_logging;
7989 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7990 return D_O_K;
7991 }
7992 // int32_t devDebug()
7993 // {
7994 // dev_debug = !dev_debug;
7995 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7996 // return D_O_K;
7997 // }
7998 int32_t devTimestmp()
7999 {
8000 dev_timestmp = !dev_timestmp;
8001 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
8002 return D_O_K;
8003 }
8004 #if DEVLEVEL > 1
8005 int32_t setCheat()
8006 {
8007 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
8008 return D_O_K;
8009 }
8010 #endif //DEVLEVEL > 1
8011 #endif //DEVLEVEL > 0
8012
8013 MENU the_player_menu[] =
8014 {
8015 { (char *)"&Game", NULL, game_menu, 0, NULL },
8016 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
8017 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
8018 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
8019 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
8020 #if DEVLEVEL > 0
8021 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
8022 #endif
8023 { NULL, NULL, NULL, 0, NULL }
8024 };
8025
8026 MENU the_player_menu2[] =
8027 {
8028 { (char *)"&Game", NULL, game_menu, 0, NULL },
8029 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
8030 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
8031 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
8032 #if DEVLEVEL > 0
8033 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
8034 #endif
8035 { NULL, NULL, NULL, 0, NULL }
8036 };
8037
8038 int32_t onMIDIPatch()
8039 {
8040 if(jwin_alert3(
8041 "Toggle Windows MIDI Fix",
8042 "This action will change whether ZC Player auto-restarts a MIDI at its",
8043 "last index if you move ZC Player out of focus, then back into focus.",
8044 "Proceed?",
8045 "&Yes",
8046 "&No",
8047 NULL,
8048 'y',
8049 'n',
8050 0,
8051 lfont) == 1)
8052 {
8053 midi_patch_fix = midi_patch_fix ? 0 : 1;
8054 zc_set_config("zeldadx","midi_patch_fix",midi_patch_fix);
8055 }
8056 fixes_menu[0].flags =(midi_patch_fix)?D_SELECTED:0;
8057 return D_O_K;
8058 }
8059
8060 int32_t onKeyboardEntry()
8061 {
8062 NameEntryMode=0;
8063 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
8064 return D_O_K;
8065 }
8066
8067 int32_t onLetterGridEntry()
8068 {
8069 NameEntryMode=1;
8070 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
8071 return D_O_K;
8072 }
8073
8074 int32_t onExtLetterGridEntry()
8075 {
8076 NameEntryMode=2;
8077 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
8078 return D_O_K;
8079 }
8080
8081 static BITMAP* oldscreen;
8082 int32_t onFullscreenMenu()
8083 {
8084 // super hacks
8085 screen = oldscreen;
8086 if (onFullscreen() == D_REDRAW)
8087 {
8088 oldscreen = screen;
8089 }
8090 screen = menu_bmp;
8091 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8092 return D_O_K;
8093 }
8094
8095 23 void fix_menu()
8096 {
8097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(!debug_enabled)
8098 23 settings_menu[18].text = NULL;
8099 23 }
8100
8101 static DIALOG system_dlg[] =
8102 {
8103 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
8104 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
8105 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
8106 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
8107 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
8108 #ifndef ALLEGRO_MACOSX
8109 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
8110 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
8111 #else
8112 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
8113 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
8114 #endif
8115 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
8116 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
8117 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
8118 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
8119 };
8120
8121 static DIALOG system_dlg2[] =
8122 {
8123 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
8124 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu2, NULL, NULL },
8125 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
8126 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
8127 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
8128 #ifndef ALLEGRO_MACOSX
8129 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
8130 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
8131 #else
8132 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
8133 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
8134 #endif
8135 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
8136 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
8137 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
8138 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
8139 };
8140
8141 void reset_snapshot_format_menu()
8142 {
8143 for(int32_t i=0; i<ssfmtMAX; ++i)
8144 {
8145 snapshot_format_menu[i].flags=0;
8146 }
8147 }
8148
8149 int32_t onSetSnapshotFormat()
8150 {
8151 switch(active_menu->text[1])
8152 {
8153 case 'B': //"&BMP"
8154 SnapshotFormat=0;
8155 break;
8156
8157 case 'G': //"&GIF"
8158 SnapshotFormat=1;
8159 break;
8160
8161 case 'J': //"&JPG"
8162 SnapshotFormat=2;
8163 break;
8164
8165 case 'P': //"&PNG"
8166 SnapshotFormat=3;
8167 break;
8168
8169 case 'C': //"PC&X"
8170 SnapshotFormat=4;
8171 break;
8172
8173 case 'T': //"&TGA"
8174 SnapshotFormat=5;
8175 break;
8176
8177 case 'L': //"&LBM"
8178 SnapshotFormat=6;
8179 break;
8180 }
8181 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
8182
8183 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
8184 return D_O_K;
8185 }
8186
8187
8188 37 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
8189 {
8190 PALETTE tmp;
8191
8192
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 37 times.
9509 for(int32_t i=0; i<256; i++)
8193 {
8194 9472 tmp[i].r=r;
8195 9472 tmp[i].g=g;
8196 9472 tmp[i].b=b;
8197 9472 }
8198
8199 37 fade_interpolate(src,tmp,dest,pos,from,to);
8200 37 }
8201
8202 37 void system_pal()
8203 {
8204 37 is_sys_pal = true;
8205 static PALETTE pal;
8206 37 copy_pal((RGB*)datafile[PAL_GUI].dat, pal);
8207
8208 // set up the grayscale palette
8209
2/2
✓ Branch 0 taken 2368 times.
✓ Branch 1 taken 37 times.
2405 for(int32_t i=128; i<192; i++)
8210 {
8211 2368 pal[i].r = i-128;
8212 2368 pal[i].g = i-128;
8213 2368 pal[i].b = i-128;
8214 2368 }
8215 37 load_colorset(gui_colorset, pal);
8216
8217 37 color_layer(pal, pal, 24,16,16, 28, 128,191);
8218
8219
2/2
✓ Branch 0 taken 4736 times.
✓ Branch 1 taken 37 times.
4773 for(int32_t i=0; i<256; i+=2)
8220 {
8221 4736 int32_t v = (i>>3)+2;
8222 4736 int32_t c = (i>>3)+192;
8223 4736 pal[c] = _RGB(v,v,v+(v>>1));
8224 /*
8225 if(i<240)
8226 {
8227 _allegro_hline(tmp_scr,0,i,319,c);
8228 _allegro_hline(tmp_scr,0,i+1,319,c);
8229 }
8230 */
8231 4736 }
8232
8233 // draw the vertical screen gradient
8234
2/2
✓ Branch 0 taken 8880 times.
✓ Branch 1 taken 37 times.
8917 for(int32_t i=0; i<240; ++i)
8235 {
8236 8880 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8237 8880 }
8238
8239 /*
8240 palrstart= 10*63/255; palrend=166*63/255;
8241 palgstart= 36*63/255; palgend=202*63/255;
8242 palbstart=106*63/255; palbend=240*63/255;
8243 paldivs=32;
8244 for(int32_t i=0; i<paldivs; i++)
8245 {
8246 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8247 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8248 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8249 }
8250 */
8251 37 BITMAP *panorama = create_bitmap_ex(8,256,224);
8252 int32_t ts_height, ts_start;
8253
8254
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
37 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8255 {
8256 clear_to_color(panorama,0);
8257 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8258 ts_height=224-passive_subscreen_height;
8259 ts_start=28;
8260 }
8261 else
8262 {
8263 37 blit(framebuf,panorama,0,0,0,0,256,224);
8264 37 ts_height=224;
8265 37 ts_start=0;
8266 }
8267
8268 // gray scale the current frame
8269
2/2
✓ Branch 0 taken 8288 times.
✓ Branch 1 taken 37 times.
8325 for(int32_t y=0; y<ts_height; y++)
8270 {
8271
2/2
✓ Branch 0 taken 2121728 times.
✓ Branch 1 taken 8288 times.
2130016 for(int32_t x=0; x<256; x++)
8272 {
8273 2121728 int32_t c = panorama->line[y+ts_start][x];
8274
2/2
✓ Branch 0 taken 2115838 times.
✓ Branch 1 taken 5890 times.
2121728 int32_t gray = zc_min((RAMpal[c].r*42 + RAMpal[c].g*75 + RAMpal[c].b*14) >> 7, 63);
8275 2121728 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8276 2121728 }
8277 8288 }
8278
8279 37 destroy_bitmap(panorama);
8280
8281 // display everything
8282 37 vsync();
8283 37 hw_palette = &pal;
8284 37 update_hw_pal = true;
8285
8286 // sys_pal = pal;
8287 37 memcpy(sys_pal,pal,sizeof(pal));
8288 37 }
8289
8290 void system_pal2()
8291 {
8292 is_sys_pal = true;
8293 static PALETTE RAMpal2;
8294 copy_pal((RGB*)datafile[PAL_GUI].dat, RAMpal2);
8295
8296 /* Windows 2000 colors
8297 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8298 RAMpal2[dvc(2)] = _RGB( 66*63/255, 65*63/255, 66*63/255);
8299 RAMpal2[dvc(3)] = _RGB(132*63/255, 130*63/255, 132*63/255);
8300 RAMpal2[dvc(4)] = _RGB(212*63/255, 208*63/255, 200*63/255);
8301 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8302 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8303 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8304 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8305
8306 byte palrstart= 10*63/255, palrend=166*63/255,
8307 palgstart= 36*63/255, palgend=202*63/255,
8308 palbstart=106*63/255, palbend=240*63/255,
8309 paldivs=7;
8310 for(int32_t i=0; i<paldivs; i++)
8311 {
8312 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8313 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8314 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8315 }
8316 */
8317
8318 /* Windows 98 colors
8319 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8320 RAMpal2[dvc(2)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8321 RAMpal2[dvc(3)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8322 RAMpal2[dvc(4)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8323 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8324 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8325 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8326 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8327
8328 byte palrstart= 0*63/255, palrend=166*63/255,
8329 palgstart= 0*63/255, palgend=202*63/255,
8330 palbstart=128*63/255, palbend=240*63/255,
8331 paldivs=7;
8332 for(int32_t i=0; i<paldivs; i++)
8333 {
8334 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8335 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8336 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8337 }
8338 */
8339
8340 /* Windows 99 colors
8341 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8342 RAMpal2[dvc(2)] = _RGB( 64*63/255, 64*63/255, 64*63/255);
8343 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8344 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8345 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8346 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8347 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8348 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8349 RAMpal2[dvc(9)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8350
8351 byte palrstart= 0*63/255, palrend=166*63/255,
8352 palgstart= 0*63/255, palgend=202*63/255,
8353
8354 palbstart=128*63/255, palbend=240*63/255,
8355 paldivs=6;
8356 for(int32_t i=0; i<paldivs; i++)
8357 {
8358 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8359 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8360 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8361 }
8362 */
8363
8364
8365
8366 RAMpal2[dvc(1)] = _RGB(0*63/255, 0*63/255, 0*63/255);
8367 RAMpal2[dvc(2)] = _RGB(64*63/255, 64*63/255, 64*63/255);
8368 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8369 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8370 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8371 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8372 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8373 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8374 RAMpal2[dvc(9)] = _RGB(0*63/255, 0*63/255, 80*63/255);
8375
8376 byte palrstart= 0*63/255, palrend=166*63/255,
8377 palgstart= 0*63/255, palgend=202*63/255,
8378 palbstart=128*63/255, palbend=240*63/255,
8379 paldivs=6;
8380
8381 for(int32_t i=0; i<paldivs; i++)
8382 {
8383 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8384 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8385 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8386 }
8387
8388 gui_bg_color=jwin_pal[jcBOX];
8389 gui_fg_color=jwin_pal[jcBOXFG];
8390
8391 jwin_set_colors(jwin_pal);
8392
8393
8394 // set up the new palette
8395 for(int32_t i=128; i<192; i++)
8396 {
8397 RAMpal2[i].r = i-128;
8398 RAMpal2[i].g = i-128;
8399 RAMpal2[i].b = i-128;
8400 }
8401
8402 /*
8403 for(int32_t i=0; i<64; i++)
8404 {
8405 RAMpal2[128+i] = _RGB(i,i,i)1));
8406 }
8407 */
8408
8409 /*
8410
8411 pal[vc(1)] = _RGB(0x00,0x00,0x14);
8412 pal[vc(4)] = _RGB(0x36,0x36,0x36);
8413 pal[vc(6)] = _RGB(0x10,0x10,0x10);
8414 pal[vc(7)] = _RGB(0x20,0x20,0x20);
8415 pal[vc(9)] = _RGB(0x20,0x20,0x24);
8416 pal[vc(11)] = _RGB(0x30,0x30,0x30);
8417 pal[vc(14)] = _RGB(0x3F,0x38,0x28);
8418
8419 gui_fg_color=vc(14);
8420 gui_bg_color=vc(1);
8421
8422 jwin_set_colors(jwin_pal);
8423 */
8424
8425 // color_layer(RAMpal2, RAMpal2, 24,16,16, 28, 128,191);
8426
8427 // set up the colors for the vertical screen gradient
8428 for(int32_t i=0; i<256; i+=2)
8429 {
8430 int32_t v = (i>>3)+2;
8431 int32_t c = (i>>3)+192;
8432 RAMpal2[c] = _RGB(v,v,v+(v>>1));
8433
8434 /*
8435 if(i<240)
8436 {
8437 _allegro_hline(tmp_scr,0,i,319,c);
8438 _allegro_hline(tmp_scr,0,i+1,319,c);
8439 }
8440 */
8441 }
8442
8443 // hw_palette = &RAMpal;
8444 // update_hw_pal = true;
8445
8446 for(int32_t i=0; i<240; ++i)
8447 {
8448 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8449 }
8450
8451 /*
8452 byte palrstart= 10*63/255, palrend=166*63/255,
8453 palgstart= 36*63/255, palgend=202*63/255,
8454 palbstart=106*63/255, palbend=240*63/255,
8455 paldivs=32;
8456 for(int32_t i=0; i<paldivs; i++)
8457 {
8458 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8459 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8460 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8461 }
8462 */
8463 BITMAP *panorama = create_bitmap_ex(8,256,224);
8464 int32_t ts_height, ts_start;
8465
8466 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8467 {
8468 clear_to_color(panorama,0);
8469 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8470 ts_height=224-passive_subscreen_height;
8471 ts_start=28;
8472 }
8473 else
8474 {
8475 blit(framebuf,panorama,0,0,0,0,256,224);
8476 ts_height=224;
8477 ts_start=0;
8478 }
8479
8480 // gray scale the current frame
8481 for(int32_t y=0; y<ts_height; y++)
8482 {
8483 for(int32_t x=0; x<256; x++)
8484 {
8485 int32_t c = panorama->line[y+ts_start][x];
8486 int32_t gray = zc_min((RAMpal2[c].r*42 + RAMpal2[c].g*75 + RAMpal2[c].b*14) >> 7, 63);
8487 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8488 }
8489 }
8490
8491 destroy_bitmap(panorama);
8492
8493 // display everything
8494 vsync();
8495 hw_palette = &RAMpal2;
8496 update_hw_pal = true;
8497
8498 blit(tmp_scr,screen,0,0,scrx,scry,320,240);
8499
8500 // sys_pal = pal;
8501 memcpy(sys_pal,RAMpal2,sizeof(RAMpal2));
8502 }
8503
8504 static uint32_t entered_sys_pal = 0;
8505 14 void enter_sys_pal()
8506 {
8507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(is_sys_pal)
8508 {
8509 if(entered_sys_pal)
8510 ++entered_sys_pal;
8511 return;
8512 }
8513 14 system_pal();
8514 14 ++entered_sys_pal;
8515 14 }
8516 14 void exit_sys_pal()
8517 {
8518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(entered_sys_pal)
8519 {
8520
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!--entered_sys_pal)
8521 {
8522 14 game_pal();
8523 14 }
8524 14 }
8525 14 }
8526
8527 void switch_out_callback()
8528 {
8529 if (pause_in_background)
8530 {
8531 callback_switchin = 3;
8532 return;
8533 }
8534
8535 #ifdef _WIN32
8536 if(midi_patch_fix==0 || currmidi==-1)
8537 return;
8538
8539
8540 paused_midi_pos = midi_pos;
8541 zc_stop_midi();
8542 midi_paused=true;
8543 midi_suspended = midissuspHALTED;
8544 #endif
8545 }
8546
8547 void switch_in_callback()
8548 {
8549 if(pause_in_background)
8550 {
8551 return;
8552 }
8553
8554 #ifdef _WIN32
8555 if(midi_patch_fix==0 || currmidi==-1)
8556 return;
8557
8558 else
8559 {
8560 callback_switchin = 1;
8561 midi_suspended = midissuspRESUME;
8562 }
8563 #endif
8564 }
8565
8566 188 void game_pal()
8567 {
8568 188 is_sys_pal = false;
8569 188 entered_sys_pal = 0;
8570 188 clear_to_color(screen,BLACK);
8571 188 hw_palette = &RAMpal;
8572 188 update_hw_pal = true;
8573 188 }
8574
8575 static char bar_str[] = "";
8576
8577 14 void music_pause()
8578 {
8579 //al_pause_duh(tmplayer);
8580 14 zcmusic_pause(zcmusic, ZCM_PAUSE);
8581 14 zc_midi_pause();
8582 14 midi_paused=true;
8583 14 }
8584
8585 void music_resume()
8586 {
8587 //al_resume_duh(tmplayer);
8588 zcmusic_pause(zcmusic, ZCM_RESUME);
8589 zc_midi_resume();
8590 midi_paused=false;
8591 }
8592
8593 3651 void music_stop()
8594 {
8595 //al_stop_duh(tmplayer);
8596 //unload_duh(tmusic);
8597 //tmusic=NULL;
8598 //tmplayer=NULL;
8599 3651 zcmusic_stop(zcmusic);
8600 3651 zcmusic_unload_file(zcmusic);
8601 3651 zc_stop_midi();
8602 3651 midi_paused=false;
8603 3651 currmidi=-1;
8604 3651 }
8605
8606 void System()
8607 {
8608 mouse_down=gui_mouse_b();
8609 music_pause();
8610 pause_all_sfx();
8611 MenuOpen = true;
8612 system_pal();
8613 // FONT *oldfont=font;
8614 // font=tfont;
8615
8616 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8617 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
8618
8619 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
8620 #if DEVLEVEL > 1
8621 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
8622 #endif
8623 game_menu[3].flags =
8624 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
8625 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
8626 fixes_menu[0].flags = (midi_patch_fix)?D_SELECTED:0;
8627 clear_keybuf();
8628 show_mouse(screen);
8629
8630 DIALOG_PLAYER *p;
8631
8632 clear_bitmap(menu_bmp);
8633 oldscreen = screen;
8634 screen = menu_bmp;
8635
8636 if(!Playing || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode))
8637 {
8638 p = init_dialog(system_dlg2,-1);
8639 }
8640 else
8641 {
8642 p = init_dialog(system_dlg,-1);
8643 }
8644
8645 // drop the menu on startup if menu button pressed
8646 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
8647 simulate_keypress(KEY_G << 8);
8648
8649 do
8650 {
8651 if(close_button_quit)
8652 {
8653 close_button_quit = false;
8654 f_Quit(qEXIT);
8655 if(Quit) break;
8656 }
8657 rest(17);
8658
8659 if(mouse_down && !gui_mouse_b())
8660 mouse_down=0;
8661
8662 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
8663 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
8664 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
8665
8666 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
8667 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
8668 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
8669 settings_menu[7].flags = TransLayers?D_SELECTED:0;
8670 settings_menu[8].flags = NESquit?D_SELECTED:0;
8671 settings_menu[9].flags = ClickToFreeze?D_SELECTED:0;
8672 settings_menu[10].flags = SaveDragResize?D_SELECTED:0;
8673 settings_menu[11].flags = DragAspect?D_SELECTED:0;
8674 settings_menu[12].flags = SaveWinPos?D_SELECTED:0;
8675 settings_menu[13].flags = volkeys?D_SELECTED:0;
8676 //Epilepsy Prevention
8677 settings_menu[16].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
8678
8679 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
8680 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
8681 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
8682
8683 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
8684 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
8685 misc_menu[14].flags =(clearConsoleOnLoad)?D_SELECTED:0;
8686
8687 the_player_menu[2].flags = replay_is_replaying() ? D_DISABLED : 0;
8688 cheat_menu[0].flags = 0;
8689 refill_menu[4].flags = get_bit(quest_rules, qr_TRUEARROWS) ? 0 : D_DISABLED;
8690 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
8691 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
8692 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
8693 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
8694 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
8695 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
8696 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
8697 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
8698
8699 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
8700 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
8701 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
8702 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
8703 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
8704 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
8705 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
8706 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
8707 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
8708 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
8709 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
8710 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
8711 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
8712 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
8713 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
8714
8715 settings_menu[14].flags = heart_beep ? D_SELECTED : 0;
8716 settings_menu[15].flags = use_save_indicator ? D_SELECTED : 0;
8717
8718 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8719 (char *)"Disable recording new saves" :
8720 (char *)"Enable recording new saves";
8721 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8722 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8723 (char *)"Stop recording" :
8724 (char *)"Stop replaying";
8725 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8726 replay_menu[6].text = replay_is_snapshot_all_frames() ?
8727 (char *)"Disable snapshot all frames" :
8728 (char *)"Enable snapshot all frames";
8729
8730 reset_snapshot_format_menu();
8731 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8732
8733 if(debug_enabled)
8734 {
8735 settings_menu[19].flags = get_debug() ? D_SELECTED : 0;
8736 }
8737
8738 if(gui_mouse_b() && !mouse_down)
8739 break;
8740
8741 // press menu to drop the menu
8742 if(rMbtn())
8743 simulate_keypress(KEY_G << 8);
8744
8745 if(input_idle(true) > after_time())
8746 // run Screeen Saver
8747 {
8748 // Screen saver enabled for now.
8749 clear_keybuf();
8750 scare_mouse();
8751 Matrix(ss_speed, ss_density, 0);
8752 system_pal();
8753 unscare_mouse();
8754 broadcast_dialog_message(MSG_DRAW, 0);
8755 }
8756
8757 update_hw_screen();
8758 }
8759 while(update_dialog(p));
8760
8761 screen = oldscreen;
8762
8763 // font=oldfont;
8764 mouse_down=gui_mouse_b();
8765 shutdown_dialog(p);
8766 show_mouse(NULL);
8767 MenuOpen = false;
8768 if(Quit)
8769 {
8770 kill_sfx();
8771 music_stop();
8772 update_hw_screen();
8773 }
8774 else
8775 {
8776 game_pal();
8777 music_resume();
8778 resume_all_sfx();
8779
8780 if(rc)
8781 ringcolor(false);
8782 }
8783
8784 eat_buttons();
8785
8786 rc=false;
8787 clear_keybuf();
8788 // text_mode(0);
8789 }
8790
8791 23 void fix_dialogs()
8792 {
8793 23 jwin_center_dialog(about_dlg);
8794 23 jwin_center_dialog(gamepad_dlg);
8795 23 jwin_center_dialog(credits_dlg);
8796 23 jwin_center_dialog(gamemode_dlg);
8797 23 jwin_center_dialog(getnum_dlg);
8798 23 jwin_center_dialog(goto_dlg);
8799 23 jwin_center_dialog(keyboard_control_dlg);
8800 23 jwin_center_dialog(midi_dlg);
8801 23 jwin_center_dialog(quest_dlg);
8802 23 jwin_center_dialog(scrsaver_dlg);
8803 23 jwin_center_dialog(sound_dlg);
8804 23 jwin_center_dialog(triforce_dlg);
8805
8806 // digi_dp[1] += scrx;
8807 // digi_dp[2] += scry;
8808 // midi_dp[1] += scrx;
8809 // midi_dp[2] += scry;
8810 // pan_dp[1] += scrx;
8811 // pan_dp[2] += scry;
8812 // emus_dp[1] += scrx;
8813 // emus_dp[2] += scry;
8814 // buf_dp[1] += scrx;
8815 // buf_dp[2] += scry;
8816 // sfx_dp[1] += scrx;
8817 // sfx_dp[2] += scry;
8818 23 }
8819
8820 /*****************************/
8821 /**** Custom Sound System ****/
8822 /*****************************/
8823
8824 1309 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8825 {
8826
3/4
✓ Branch 0 taken 1241 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 1309 times.
✗ Branch 3 not taken.
1309 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8827 }
8828
8829 // Run an NSF, or a MIDI if the NSF is missing somehow.
8830 64 bool try_zcmusic(char *filename, int32_t track, int32_t midi)
8831 {
8832 64 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8833
8834 // Found it
8835
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 25 times.
64 if(newzcmusic!=NULL)
8836 {
8837 39 zcmusic_stop(zcmusic);
8838 39 zcmusic_unload_file(zcmusic);
8839 39 zc_stop_midi();
8840
8841 39 zcmusic=newzcmusic;
8842 39 zcmusic_play(zcmusic, emusic_volume);
8843
8844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
39 if(track>0)
8845 39 zcmusic_change_track(zcmusic,track);
8846
8847 39 return true;
8848 }
8849
8850 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8851
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 else if(midi>-1000)
8852 jukebox(midi);
8853
8854 25 return false;
8855 64 }
8856
8857 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8858 {
8859 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8860 // Found it
8861 if(newzcmusic!=NULL)
8862 {
8863 zcmusic_stop(zcmusic);
8864 zcmusic_unload_file(zcmusic);
8865 zc_stop_midi();
8866
8867 zcmusic=newzcmusic;
8868 zcmusic_play(zcmusic, emusic_volume);
8869
8870 if(track>0)
8871 zcmusic_change_track(zcmusic,track);
8872
8873 return true;
8874 }
8875
8876 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8877 else if(midi>-1000)
8878 jukebox(midi);
8879
8880 return false;
8881 }
8882
8883 int32_t get_zcmusicpos()
8884 {
8885 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8886 return debugtracething;
8887 return 0;
8888 }
8889
8890 void set_zcmusicpos(int32_t position)
8891 {
8892 zcmusic_set_curpos(zcmusic, position);
8893 }
8894
8895 void set_zcmusicspeed(int32_t speed)
8896 {
8897 int32_t newspeed = vbound(speed, 0, 10000);
8898 zcmusic_set_speed(zcmusic, newspeed);
8899 }
8900
8901 643 void jukebox(int32_t index,int32_t loop)
8902 {
8903 643 music_stop();
8904
8905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 643 times.
643 if(index<0) index=MAXMIDIS-1;
8906
8907
1/2
✓ Branch 0 taken 643 times.
✗ Branch 1 not taken.
643 if(index>=MAXMIDIS) index=0;
8908
8909 643 music_stop();
8910
8911 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8912 // stuck notes when a song stops. This fixes it.
8913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 643 times.
643 if(strcmp(midi_driver->name, "DIGMID")==0)
8914 zc_set_volume(0, 0);
8915
8916 643 zc_set_volume(-1, mixvol(tunes[index].volume,midi_volume>>1));
8917 643 zc_play_midi((MIDI*)tunes[index].data,loop);
8918
8919
2/2
✓ Branch 0 taken 502 times.
✓ Branch 1 taken 141 times.
643 if(tunes[index].start>0)
8920 141 zc_midi_seek(tunes[index].start);
8921
8922 643 midi_loop_start = tunes[index].loop_start;
8923 643 midi_loop_end = tunes[index].loop_end;
8924
8925 643 currmidi=index;
8926 643 master_volume(digi_volume,midi_volume);
8927 643 midi_paused=false;
8928 643 }
8929
8930 4607 void jukebox(int32_t index)
8931 {
8932
1/2
✓ Branch 0 taken 4607 times.
✗ Branch 1 not taken.
4607 if(index<0) index=MAXMIDIS-1;
8933
8934
1/2
✓ Branch 0 taken 4607 times.
✗ Branch 1 not taken.
4607 if(index>=MAXMIDIS) index=0;
8935
8936 // do nothing if it's already playing
8937
3/4
✓ Branch 0 taken 3964 times.
✓ Branch 1 taken 643 times.
✓ Branch 2 taken 3964 times.
✗ Branch 3 not taken.
4607 if(index==currmidi && midi_pos>=0)
8938 {
8939 3964 midi_paused=false;
8940 3964 return;
8941 }
8942
8943 643 jukebox(index,tunes[index].loop);
8944 4607 }
8945
8946 5699 void play_DmapMusic()
8947 {
8948 static char tfile[2048];
8949 static int32_t ttrack=0;
8950 5699 bool domidi=false;
8951
8952
2/2
✓ Branch 0 taken 1201 times.
✓ Branch 1 taken 4498 times.
5699 if(DMaps[currdmap].tmusic[0]!=0)
8953 {
8954
3/4
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 816 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 385 times.
1586 if(zcmusic==NULL ||
8955
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8956
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8957 {
8958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 816 times.
816 if(zcmusic != NULL)
8959 {
8960 zcmusic_stop(zcmusic);
8961 zcmusic_unload_file(zcmusic);
8962 zcmusic = NULL;
8963 }
8964
8965 816 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8966
8967
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 730 times.
816 if(zcmusic!=NULL)
8968 {
8969 86 zc_stop_midi();
8970 86 strcpy(tfile,DMaps[currdmap].tmusic);
8971 86 zcmusic_play(zcmusic, emusic_volume);
8972 86 int32_t temptracks=0;
8973 86 temptracks=zcmusic_get_tracks(zcmusic);
8974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 temptracks=(temptracks<2)?1:temptracks;
8975 86 ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1);
8976 86 zcmusic_change_track(zcmusic,ttrack);
8977 86 }
8978 else
8979 {
8980 730 tfile[0] = 0;
8981 730 domidi=true;
8982 }
8983 816 }
8984 1201 }
8985 else
8986 {
8987 4498 domidi=true;
8988 }
8989
8990
2/2
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 5228 times.
5699 if(domidi)
8991 {
8992 5228 int32_t m=DMaps[currdmap].midi;
8993
8994
3/4
✓ Branch 0 taken 5130 times.
✓ Branch 1 taken 88 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
5228 switch(m)
8995 {
8996 case 1:
8997 88 jukebox(ZC_MIDI_OVERWORLD);
8998 88 break;
8999
9000 case 2:
9001 10 jukebox(ZC_MIDI_DUNGEON);
9002 10 break;
9003
9004 case 3:
9005 jukebox(ZC_MIDI_LEVEL9);
9006 break;
9007
9008 default:
9009
3/4
✓ Branch 0 taken 4389 times.
✓ Branch 1 taken 741 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4389 times.
5130 if(m>=4 && m<4+MAXCUSTOMMIDIS)
9010 4389 jukebox(m+MIDIOFFSET_DMAP);
9011 else
9012 741 music_stop();
9013 5130 }
9014 5228 }
9015 5699 }
9016
9017 5736 void playLevelMusic()
9018 {
9019 5736 int32_t m=tmpscr->screen_midi;
9020
9021
3/6
✓ Branch 0 taken 5683 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41 times.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
5736 switch(m)
9022 {
9023 case -2:
9024 12 music_stop();
9025 12 break;
9026
9027 case -1:
9028 5683 play_DmapMusic();
9029 5683 break;
9030
9031 case 1:
9032 jukebox(ZC_MIDI_OVERWORLD);
9033 break;
9034
9035 case 2:
9036 jukebox(ZC_MIDI_DUNGEON);
9037 break;
9038
9039 case 3:
9040 jukebox(ZC_MIDI_LEVEL9);
9041 break;
9042
9043 default:
9044
2/4
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
41 if(m>=4 && m<4+MAXCUSTOMMIDIS)
9045 41 jukebox(m+MIDIOFFSET_MAPSCR);
9046 else
9047 music_stop();
9048 41 }
9049 5736 }
9050
9051 666 void master_volume(int32_t dv,int32_t mv)
9052 {
9053
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 666 times.
✓ Branch 2 taken 666 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 666 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 666 times.
✗ Branch 7 not taken.
666 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
9054
9055
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 666 times.
✓ Branch 2 taken 666 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 666 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 666 times.
✗ Branch 7 not taken.
666 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
9056
9057
6/6
✓ Branch 0 taken 642 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 665 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 641 times.
✓ Branch 5 taken 24 times.
666 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
9058 666 zc_set_volume(digi_volume,mixvol(tunes[i].volume,midi_volume));
9059 666 }
9060
9061 /*****************/
9062 /***** SFX *****/
9063 /*****************/
9064
9065 // array of voices, one for each sfx sample in the data file
9066 // 0+ = voice #
9067 // -1 = voice not allocated
9068 23 void Z_init_sound()
9069 {
9070
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 23 times.
5911 for(int32_t i=0; i<WAV_COUNT; i++)
9071 5888 sfx_voice[i]=-1;
9072
9073
2/2
✓ Branch 0 taken 161 times.
✓ Branch 1 taken 23 times.
184 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
9074 161 tunes[i].data = (MIDI*)mididata[i].dat;
9075
9076
2/2
✓ Branch 0 taken 5796 times.
✓ Branch 1 taken 23 times.
5819 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
9077 5796 tunes[ZC_MIDI_COUNT+j].data=NULL;
9078
9079 23 master_volume(digi_volume,midi_volume);
9080 23 }
9081
9082 // returns number of voices currently allocated
9083 int32_t sfx_count()
9084 {
9085 int32_t c=0;
9086
9087 for(int32_t i=0; i<WAV_COUNT; i++)
9088 if(sfx_voice[i]!=-1)
9089 ++c;
9090
9091 return c;
9092 }
9093
9094 // clean up finished samples
9095 4322998 void sfx_cleanup()
9096 {
9097
2/2
✓ Branch 0 taken 1106687488 times.
✓ Branch 1 taken 4322998 times.
1111010486 for(int32_t i=0; i<WAV_COUNT; i++)
9098
3/4
✓ Branch 0 taken 430539 times.
✓ Branch 1 taken 1106256949 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 430539 times.
1107118027 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
9099 {
9100 430539 deallocate_voice(sfx_voice[i]);
9101 430539 sfx_voice[i]=-1;
9102 430539 }
9103 4322998 }
9104
9105 // allocates a voice for the sample "wav_index" (index into zelda.dat)
9106 // if a voice is already allocated (and/or playing), then it just returns true
9107 // Returns true: voice is allocated
9108 // false: unsuccessful
9109 527783 bool sfx_init(int32_t index)
9110 {
9111 // check index
9112
3/4
✓ Branch 0 taken 467925 times.
✓ Branch 1 taken 59858 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 467925 times.
527783 if(index<=0 || index>=WAV_COUNT)
9113 59858 return false;
9114
9115
2/2
✓ Branch 0 taken 37366 times.
✓ Branch 1 taken 430559 times.
467925 if(sfx_voice[index]==-1)
9116 {
9117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 430559 times.
430559 if(sfxdat)
9118 {
9119 if(index<Z35)
9120 {
9121 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
9122 }
9123 else
9124 {
9125 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
9126 }
9127 }
9128 else
9129 {
9130 430559 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
9131 }
9132
9133 430559 voice_set_volume(sfx_voice[index], sfx_volume);
9134 430559 }
9135
9136 467925 return sfx_voice[index] != -1;
9137 527783 }
9138
9139 // plays an sfx sample
9140 435537 void sfx(int32_t index,int32_t pan,bool loop, bool restart)
9141 {
9142
2/2
✓ Branch 0 taken 406935 times.
✓ Branch 1 taken 28602 times.
435537 if(!sfx_init(index))
9143 28602 return;
9144
9145 406935 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
9146 406935 voice_set_pan(sfx_voice[index],pan);
9147
9148 406935 int32_t pos = voice_get_position(sfx_voice[index]);
9149
9150
2/2
✓ Branch 0 taken 227733 times.
✓ Branch 1 taken 179202 times.
406935 if(restart) voice_set_position(sfx_voice[index],0);
9151
9152
1/2
✓ Branch 0 taken 406935 times.
✗ Branch 1 not taken.
406935 if(pos<=0)
9153 406935 voice_start(sfx_voice[index]);
9154 435537 }
9155
9156 // true if sfx is allocated
9157 21668 bool sfx_allocated(int32_t index)
9158 {
9159
2/4
✓ Branch 0 taken 21668 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21668 times.
21668 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
9160 }
9161
9162 // start it (in loop mode) if it's not already playing,
9163 // otherwise adjust it to play in loop mode -DD
9164 92246 void cont_sfx(int32_t index)
9165 {
9166
2/2
✓ Branch 0 taken 31256 times.
✓ Branch 1 taken 60990 times.
92246 if(!sfx_init(index))
9167 {
9168 31256 return;
9169 }
9170
9171
1/2
✓ Branch 0 taken 60990 times.
✗ Branch 1 not taken.
60990 if(voice_get_position(sfx_voice[index])<=0)
9172 {
9173 60990 voice_set_position(sfx_voice[index],0);
9174 60990 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
9175 60990 voice_start(sfx_voice[index]);
9176 60990 }
9177 else
9178 {
9179 adjust_sfx(index, 128, true);
9180 }
9181 92246 }
9182
9183 // adjust parameters while playing
9184 2684 void adjust_sfx(int32_t index,int32_t pan,bool loop)
9185 {
9186
5/6
✓ Branch 0 taken 1518 times.
✓ Branch 1 taken 1166 times.
✓ Branch 2 taken 1518 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 1506 times.
2684 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
9187 2672 return;
9188
9189 12 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
9190 12 voice_set_pan(sfx_voice[index],pan);
9191 2684 }
9192
9193 // pauses a voice
9194 965 void pause_sfx(int32_t index)
9195 {
9196
3/6
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 965 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 965 times.
965 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
9197 voice_stop(sfx_voice[index]);
9198 965 }
9199
9200 // resumes a voice
9201 460 void resume_sfx(int32_t index)
9202 {
9203
3/6
✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 460 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 460 times.
460 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
9204 voice_start(sfx_voice[index]);
9205 460 }
9206
9207 // pauses all active voices
9208 113 void pause_all_sfx()
9209 {
9210
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 113 times.
29041 for(int32_t i=0; i<WAV_COUNT; i++)
9211
2/2
✓ Branch 0 taken 28926 times.
✓ Branch 1 taken 2 times.
28930 if(sfx_voice[i]!=-1)
9212 2 voice_stop(sfx_voice[i]);
9213 113 }
9214
9215 // resumes all paused voices
9216 99 void resume_all_sfx()
9217 {
9218
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<WAV_COUNT; i++)
9219
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(sfx_voice[i]!=-1)
9220 voice_start(sfx_voice[i]);
9221 99 }
9222
9223 // stops an sfx and deallocates the voice
9224 3412085 void stop_sfx(int32_t index)
9225 {
9226
3/4
✓ Branch 0 taken 3323874 times.
✓ Branch 1 taken 88211 times.
✓ Branch 2 taken 3323874 times.
✗ Branch 3 not taken.
3412085 if(index<=0 || index>=WAV_COUNT)
9227 88211 return;
9228
9229
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3323861 times.
3323874 if(sfx_voice[index]!=-1)
9230 {
9231 13 deallocate_voice(sfx_voice[index]);
9232 13 sfx_voice[index]=-1;
9233 13 }
9234 3412085 }
9235
9236 // Stops SFX played by Hero's item of the given family
9237 17098 void stop_item_sfx(int32_t family)
9238 {
9239 17098 int32_t id=current_item_id(family);
9240
9241
2/2
✓ Branch 0 taken 16832 times.
✓ Branch 1 taken 266 times.
17098 if(id<0)
9242 16832 return;
9243
9244 266 stop_sfx(itemsbuf[id].usesound);
9245 17098 }
9246
9247 1163 void kill_sfx()
9248 {
9249
2/2
✓ Branch 0 taken 297728 times.
✓ Branch 1 taken 1163 times.
298891 for(int32_t i=0; i<WAV_COUNT; i++)
9250
2/2
✓ Branch 0 taken 297721 times.
✓ Branch 1 taken 7 times.
297735 if(sfx_voice[i]!=-1)
9251 {
9252 7 deallocate_voice(sfx_voice[i]);
9253 7 sfx_voice[i]=-1;
9254 7 }
9255 1163 }
9256
9257 366927 int32_t pan(int32_t x)
9258 {
9259
1/4
✓ Branch 0 taken 366927 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
366927 switch(pan_style)
9260 {
9261 case 0:
9262 return 128;
9263
9264 case 1:
9265 366927 return vbound((x>>1)+68,0,255);
9266
9267 case 2:
9268 return vbound(((x*3)>>2)+36,0,255);
9269 }
9270
9271 return vbound(x,0,255);
9272 366927 }
9273
9274 /*******************************/
9275 /******* Input Handlers ********/
9276 /*******************************/
9277
9278 10159687 bool joybtn(int32_t b)
9279 {
9280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10159687 times.
10159687 if(b == 0)
9281 return false;
9282
9283 10159687 return joy[joystick_index].button[b-1].b !=0;
9284 10159687 }
9285
9286 const char* joybtn_name(int32_t b)
9287 {
9288 if(b == 0)
9289 return "";
9290
9291 return joy[joystick_index].button[b-1].name;
9292 }
9293
9294 int32_t next_press_key()
9295 {
9296 return readkey()>>8;
9297 }
9298
9299 int32_t next_press_btn()
9300 {
9301 clear_keybuf();
9302 /*bool b[joy[joystick_index].num_buttons+1];
9303
9304 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9305 b[i]=joybtn(i);*/
9306
9307 //first, we need to wait until they're pressing no buttons
9308 for(;;)
9309 {
9310 if(keypressed())
9311 {
9312 switch(readkey()>>8)
9313 {
9314 case KEY_ESC:
9315 return -1;
9316
9317 case KEY_SPACE:
9318 return 0;
9319 }
9320 }
9321
9322 poll_joystick();
9323 bool done = true;
9324
9325 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9326 {
9327 if(joybtn(i)) done = false;
9328 }
9329
9330 if(done) break;
9331 rest(1);
9332 }
9333
9334 //now, we need to wait for them to press any button
9335 for(;;)
9336 {
9337 if(keypressed())
9338 {
9339 switch(readkey()>>8)
9340 {
9341 case KEY_ESC:
9342 return -1;
9343
9344 case KEY_SPACE:
9345 return 0;
9346 }
9347 }
9348
9349 poll_joystick();
9350
9351 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9352 {
9353 if(joybtn(i)) return i;
9354 }
9355 rest(1);
9356 }
9357 }
9358
9359 88531346 static bool rButton(bool &btn, bool &flag, bool* rawbtn = nullptr)
9360 {
9361
2/2
✓ Branch 0 taken 85357392 times.
✓ Branch 1 taken 3173954 times.
88531346 bool ret = btn && !flag;
9362
2/2
✓ Branch 0 taken 83932385 times.
✓ Branch 1 taken 4598961 times.
88531346 flag = rawbtn ? *rawbtn : btn;
9363
9364 88531346 return ret;
9365 }
9366 864 static bool rButtonPeek(bool btn, bool flag)
9367 {
9368
2/2
✓ Branch 0 taken 828 times.
✓ Branch 1 taken 36 times.
864 if(!btn)
9369 {
9370 828 return false;
9371 }
9372
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 27 times.
36 else if(!flag)
9373 {
9374 9 return true;
9375 }
9376
9377 27 return false;
9378 864 }
9379
9380 // Updated only by keyboard/gamepad.
9381 // If in replay mode, this is set directly by the replay system.
9382 // This should never be read from directly - use control_state instead.
9383 bool raw_control_state[ZC_CONTROL_STATES];
9384
9385 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
9386 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
9387 // lasts until the next call to load_control_state.
9388 bool control_state[ZC_CONTROL_STATES];
9389 bool disable_control[ZC_CONTROL_STATES];
9390 bool drunk_toggle_state[11];
9391 bool disabledKeys[127];
9392 bool KeyInput[127];
9393 bool KeyPress[127];
9394
9395 bool key_current_frame[127];
9396 bool key_previous_frame[127];
9397
9398 static bool key_system[127];
9399 static bool key_system_previous[127];
9400 static bool key_system_press[127];
9401
9402 bool button_press[ZC_CONTROL_STATES];
9403 bool button_hold[ZC_CONTROL_STATES];
9404
9405 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
9406 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
9407 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
9408 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
9409 #define STICK_PRECISION 56 //define your own sensitivity
9410
9411 3565899 void load_control_state()
9412 {
9413
4/4
✓ Branch 0 taken 3565896 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 694695 times.
✓ Branch 3 taken 2871201 times.
3565899 if (!replay_is_active() || replay_get_version() >= 8)
9414 {
9415
2/2
✓ Branch 0 taken 12504564 times.
✓ Branch 1 taken 694698 times.
13199262 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9416 12504564 down_control_states[i] = raw_control_state[i];
9417 694698 }
9418
9419
1/2
✓ Branch 0 taken 3565899 times.
✗ Branch 1 not taken.
3565899 if (!replay_is_replaying())
9420 {
9421 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
9422 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
9423 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
9424 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
9425 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
9426 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
9427 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
9428 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
9429 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
9430 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
9431 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
9432 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
9433 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
9434 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
9435
9436 if(num_joysticks != 0)
9437 {
9438 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
9439 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
9440 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
9441 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
9442 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
9443 }
9444 else
9445 {
9446 raw_control_state[14] = false;
9447 raw_control_state[15] = false;
9448 raw_control_state[16] = false;
9449 raw_control_state[17] = false;
9450 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
9451 }
9452 }
9453
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3565896 times.
3565899 if (replay_is_active())
9454 {
9455
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 2550681 times.
3565896 if (replay_get_version() < 3)
9456 1015215 replay_poll();
9457
3/4
✓ Branch 0 taken 2550681 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 789306 times.
✓ Branch 3 taken 1761375 times.
2550681 else if (replay_is_replaying() && replay_get_version() < 6)
9458 1761375 replay_peek_input();
9459
3/4
✓ Branch 0 taken 789306 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94608 times.
✓ Branch 3 taken 694698 times.
789306 else if (replay_is_replaying() && replay_get_version() >= 8)
9460 694698 replay_peek_input();
9461 3565896 }
9462
9463
3/4
✓ Branch 0 taken 3565893 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 694698 times.
✓ Branch 3 taken 2871195 times.
3565899 if (!replay_is_active() || replay_get_version() >= 8)
9464 694698 update_keys();
9465
9466 // Some test replay files were made before a serious input bug was fixed, so instead
9467 // of re-doing them or tossing them out, just check for that zplay version.
9468
3/4
✓ Branch 0 taken 3565893 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 3443993 times.
3565893 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
9469
2/2
✓ Branch 0 taken 3565893 times.
✓ Branch 1 taken 64186074 times.
67751967 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9470 {
9471 64186074 control_state[i] = raw_control_state[i];
9472
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 14698764 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
64186074 if (botched_input && !control_state[i])
9473 47077142 down_control_states[i] = false;
9474 64186074 }
9475
9476 3565893 button_press[0]=rButton(control_state[0],button_hold[0]);
9477 3565893 button_press[1]=rButton(control_state[1],button_hold[1]);
9478 3565893 button_press[2]=rButton(control_state[2],button_hold[2]);
9479 3565893 button_press[3]=rButton(control_state[3],button_hold[3]);
9480 3565893 button_press[4]=rButton(control_state[4],button_hold[4]);
9481 3565893 button_press[5]=rButton(control_state[5],button_hold[5]);
9482 3565893 button_press[6]=rButton(control_state[6],button_hold[6]);
9483 3565893 button_press[7]=rButton(control_state[7],button_hold[7]);
9484 3565893 button_press[8]=rButton(control_state[8],button_hold[8]);
9485 3565893 button_press[9]=rButton(control_state[9],button_hold[9]);
9486 3565893 button_press[10]=rButton(control_state[10],button_hold[10]);
9487 3565893 button_press[11]=rButton(control_state[11],button_hold[11]);
9488 3565893 button_press[12]=rButton(control_state[12],button_hold[12]);
9489 3565893 button_press[13]=rButton(control_state[13],button_hold[13]);
9490 3565893 button_press[14]=rButton(control_state[14],button_hold[14]);
9491 3565893 button_press[15]=rButton(control_state[15],button_hold[15]);
9492 3565893 button_press[16]=rButton(control_state[16],button_hold[16]);
9493 3565893 button_press[17]=rButton(control_state[17],button_hold[17]);
9494 3565893 }
9495
9496 // Returns true if any game key is pressed. This is needed because keypressed()
9497 // doesn't detect modifier keys and control_state[] can be modified by scripts.
9498 18339752 bool zc_key_pressed()
9499 //may also need to use zc_getrawkey
9500 {
9501
7/10
✓ Branch 0 taken 14772220 times.
✓ Branch 1 taken 3567532 times.
✓ Branch 2 taken 3567532 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3567532 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2984244 times.
✓ Branch 7 taken 2984244 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 990988 times.
19330740 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
9502
4/6
✓ Branch 0 taken 2984244 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2984244 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2240513 times.
✓ Branch 5 taken 2240513 times.
2984244 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
9503
4/6
✓ Branch 0 taken 2240513 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2240513 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1432819 times.
✓ Branch 5 taken 1432819 times.
2240513 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
9504
4/6
✓ Branch 0 taken 1432819 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1432819 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1140303 times.
✓ Branch 5 taken 1140303 times.
1432819 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
9505
1/2
✓ Branch 0 taken 1140303 times.
✗ Branch 1 not taken.
1140303 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
9506
3/4
✓ Branch 0 taken 1065726 times.
✓ Branch 1 taken 74577 times.
✓ Branch 2 taken 1065726 times.
✗ Branch 3 not taken.
1140303 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
9507
3/4
✓ Branch 0 taken 1005266 times.
✓ Branch 1 taken 60460 times.
✓ Branch 2 taken 1005266 times.
✗ Branch 3 not taken.
1065726 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
9508
3/4
✓ Branch 0 taken 999587 times.
✓ Branch 1 taken 5679 times.
✓ Branch 2 taken 999587 times.
✗ Branch 3 not taken.
1005266 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
9509
3/4
✓ Branch 0 taken 992215 times.
✓ Branch 1 taken 7372 times.
✓ Branch 2 taken 992215 times.
✗ Branch 3 not taken.
999587 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
9510
3/4
✓ Branch 0 taken 991815 times.
✓ Branch 1 taken 400 times.
✓ Branch 2 taken 991815 times.
✗ Branch 3 not taken.
992215 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
9511
3/4
✓ Branch 0 taken 991773 times.
✓ Branch 1 taken 42 times.
✓ Branch 2 taken 991773 times.
✗ Branch 3 not taken.
991815 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
9512
3/4
✓ Branch 0 taken 991007 times.
✓ Branch 1 taken 766 times.
✓ Branch 2 taken 991007 times.
✗ Branch 3 not taken.
991773 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
9513
2/4
✓ Branch 0 taken 991007 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 991007 times.
✗ Branch 3 not taken.
991007 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
9514
2/2
✓ Branch 0 taken 990988 times.
✓ Branch 1 taken 19 times.
991007 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
9515 32944522 return true;
9516
9517 990988 return false;
9518 4391070 }
9519
9520 70668098 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9521 {
9522 70668098 bool ret = false, drunkstate = false, rawret = false;
9523 70668098 bool* flag = &down_control_states[btn];
9524
2/7
✓ Branch 0 taken 66272329 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 4395769 times.
70668098 switch(btn)
9525 {
9526 case btnF12:
9527 ret = zc_getkey(KEY_F12, ignoreDisable);
9528 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
9529 eatEntirely = false;
9530 break;
9531 case btnF11:
9532 ret = zc_getkey(KEY_F11, ignoreDisable);
9533 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
9534 eatEntirely = false;
9535 break;
9536 case btnF5:
9537 ret = zc_getkey(KEY_F5, ignoreDisable);
9538 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
9539 eatEntirely = false;
9540 break;
9541 case btnQ:
9542 ret = zc_getkey(KEY_Q, ignoreDisable);
9543 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
9544 eatEntirely = false;
9545 break;
9546 case btnI:
9547 ret = zc_getkey(KEY_I, ignoreDisable);
9548 rawret = zc_getrawkey(KEY_I, ignoreDisable);
9549 eatEntirely = false;
9550 break;
9551 case btnM:
9552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4395769 times.
4395769 if(FFCore.kb_typing_mode) return false;
9553 4395769 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
9554 4395769 eatEntirely = false;
9555 4395769 break;
9556 default: //control_state[] index
9557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66272329 times.
66272329 if(FFCore.kb_typing_mode) return false;
9558
5/6
✓ Branch 0 taken 66123060 times.
✓ Branch 1 taken 149269 times.
✓ Branch 2 taken 1900903 times.
✓ Branch 3 taken 64222157 times.
✓ Branch 4 taken 1900903 times.
✗ Branch 5 not taken.
66272329 if(!ignoreDisable && get_bit(quest_rules, qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
9559
2/2
✓ Branch 0 taken 3614301 times.
✓ Branch 1 taken 62658028 times.
66272329 else if(btn<11) drunkstate = drunk_toggle_state[btn];
9560
4/4
✓ Branch 0 taken 59314895 times.
✓ Branch 1 taken 6957434 times.
✓ Branch 2 taken 1152 times.
✓ Branch 3 taken 6956282 times.
73229763 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
9561 66272329 rawret = raw_control_state[btn];
9562 66272329 }
9563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70668098 times.
70668098 assert(flag);
9564
2/2
✓ Branch 0 taken 46321962 times.
✓ Branch 1 taken 24346136 times.
70668098 if(press)
9565 {
9566
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 24345272 times.
24346136 if(peek)
9567 864 ret = rButtonPeek(ret, *flag);
9568
3/4
✓ Branch 0 taken 24345272 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4598961 times.
✓ Branch 3 taken 19746311 times.
24345272 else if (replay_is_active() && replay_get_version() < 8) ret = rButton(ret, *flag);
9569 4598961 else ret = rButton(ret, *flag, &rawret);
9570 24346136 }
9571
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 70668098 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
70668098 if(eatEntirely && ret) control_state[btn] = false;
9572
3/4
✓ Branch 0 taken 54196208 times.
✓ Branch 1 taken 16471890 times.
✓ Branch 2 taken 54196208 times.
✗ Branch 3 not taken.
70668098 if(drunk && drunkstate) ret = !ret;
9573 70668098 return ret;
9574 70668098 }
9575
9576 369200 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9577 {
9578 369200 byte ret = 0;
9579
2/2
✓ Branch 0 taken 366817 times.
✓ Branch 1 taken 2383 times.
369200 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
9580
1/2
✓ Branch 0 taken 369200 times.
✗ Branch 1 not taken.
369200 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
9581
1/2
✓ Branch 0 taken 369200 times.
✗ Branch 1 not taken.
369200 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
9582
1/2
✓ Branch 0 taken 369200 times.
✗ Branch 1 not taken.
369200 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
9583
1/2
✓ Branch 0 taken 369200 times.
✗ Branch 1 not taken.
369200 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
9584
1/2
✓ Branch 0 taken 369200 times.
✗ Branch 1 not taken.
369200 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
9585
1/2
✓ Branch 0 taken 369200 times.
✗ Branch 1 not taken.
369200 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
9586
1/2
✓ Branch 0 taken 369200 times.
✗ Branch 1 not taken.
369200 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
9587 369200 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
9588 }
9589
9590 561 byte checkIntBtnVal(byte intbtn, byte vals)
9591 {
9592 561 return intbtn&vals;
9593 }
9594
9595 741878 bool Up()
9596 {
9597 741878 return getInput(btnUp);
9598 }
9599 39102 bool Down()
9600 {
9601 39102 return getInput(btnDown);
9602 }
9603 61082 bool Left()
9604 {
9605 61082 return getInput(btnLeft);
9606 }
9607 64571 bool Right()
9608 {
9609 64571 return getInput(btnRight);
9610 }
9611 37406 bool cAbtn()
9612 {
9613 37406 return getInput(btnA);
9614 }
9615 661269 bool cBbtn()
9616 {
9617 661269 return getInput(btnB);
9618 }
9619 bool cSbtn()
9620 {
9621 return getInput(btnS);
9622 }
9623 6440 bool cLbtn()
9624 {
9625 6440 return getInput(btnL);
9626 }
9627 6440 bool cRbtn()
9628 {
9629 6440 return getInput(btnR);
9630 }
9631 bool cPbtn()
9632 {
9633 return getInput(btnP);
9634 }
9635 bool cEx1btn()
9636 {
9637 return getInput(btnEx1);
9638 }
9639 bool cEx2btn()
9640 {
9641 return getInput(btnEx2);
9642 }
9643 bool cEx3btn()
9644 {
9645 return getInput(btnEx3);
9646 }
9647 bool cEx4btn()
9648 {
9649 return getInput(btnEx4);
9650 }
9651 bool AxisUp()
9652 {
9653 return getInput(btnAxisUp);
9654 }
9655 bool AxisDown()
9656 {
9657 return getInput(btnAxisDown);
9658 }
9659 bool AxisLeft()
9660 {
9661 return getInput(btnAxisLeft);
9662 }
9663 bool AxisRight()
9664 {
9665 return getInput(btnAxisRight);
9666 }
9667
9668 bool cMbtn()
9669 {
9670 return getInput(btnM);
9671 }
9672 bool cF12()
9673 {
9674 return getInput(btnF12);
9675 }
9676 bool cF11()
9677 {
9678 return getInput(btnF11);
9679 }
9680 bool cF5()
9681 {
9682 return getInput(btnF5);
9683 }
9684 bool cQ()
9685 {
9686 return getInput(btnQ);
9687 }
9688 bool cI()
9689 {
9690 return getInput(btnI);
9691 }
9692
9693 66879 bool rUp()
9694 {
9695 66879 return getInput(btnUp, true);
9696 }
9697 66835 bool rDown()
9698 {
9699 66835 return getInput(btnDown, true);
9700 }
9701 66805 bool rLeft()
9702 {
9703 66805 return getInput(btnLeft, true);
9704 }
9705 66396 bool rRight()
9706 {
9707 66396 return getInput(btnRight, true);
9708 }
9709 357 bool rAbtn()
9710 {
9711 357 return getInput(btnA, true);
9712 }
9713 67218 bool rBbtn()
9714 {
9715 67218 return getInput(btnB, true);
9716 }
9717 3463000 bool rSbtn()
9718 {
9719 3463000 return getInput(btnS, true);
9720 }
9721 4391070 bool rMbtn()
9722 {
9723 4391070 return getInput(btnM, true);
9724 }
9725 66242 bool rLbtn()
9726 {
9727 66242 return getInput(btnL, true);
9728 }
9729 66239 bool rRbtn()
9730 {
9731 66239 return getInput(btnR, true);
9732 }
9733 3401671 bool rPbtn()
9734 {
9735 3401671 return getInput(btnP, true);
9736 }
9737 bool rEx1btn()
9738 {
9739 return getInput(btnEx1, true);
9740 }
9741 bool rEx2btn()
9742 {
9743 return getInput(btnEx2, true);
9744 }
9745 66799 bool rEx3btn()
9746 {
9747 66799 return getInput(btnEx3, true);
9748 }
9749 66799 bool rEx4btn()
9750 {
9751 66799 return getInput(btnEx4, true);
9752 }
9753 bool rAxisUp()
9754 {
9755 return getInput(btnAxisUp, true);
9756 }
9757 bool rAxisDown()
9758 {
9759 return getInput(btnAxisDown, true);
9760 }
9761 bool rAxisLeft()
9762 {
9763 return getInput(btnAxisLeft, true);
9764 }
9765 bool rAxisRight()
9766 {
9767 return getInput(btnAxisRight, true);
9768 }
9769
9770 bool rF11()
9771 {
9772 return getInput(btnF11, true);
9773 }
9774 bool rQ()
9775 {
9776 return getInput(btnQ, true);
9777 }
9778 bool rI()
9779 {
9780 return getInput(btnI, true);
9781 }
9782
9783 8923337 bool DrunkUp()
9784 {
9785 8923337 return getInput(btnUp, false, true);
9786 }
9787 8304898 bool DrunkDown()
9788 {
9789 8304898 return getInput(btnDown, false, true);
9790 }
9791 5429974 bool DrunkLeft()
9792 {
9793 5429974 return getInput(btnLeft, false, true);
9794 }
9795 4783686 bool DrunkRight()
9796 {
9797 4783686 return getInput(btnRight, false, true);
9798 }
9799 3877357 bool DrunkcAbtn()
9800 {
9801 3877357 return getInput(btnA, false, true);
9802 }
9803 3751230 bool DrunkcBbtn()
9804 {
9805 3751230 return getInput(btnB, false, true);
9806 }
9807 3394924 bool DrunkcEx1btn()
9808 {
9809 3394924 return getInput(btnEx1, false, true);
9810 }
9811 3394944 bool DrunkcEx2btn()
9812 {
9813 3394944 return getInput(btnEx2, false, true);
9814 }
9815 bool DrunkcSbtn()
9816 {
9817 return getInput(btnS, false, true);
9818 }
9819 bool DrunkcMbtn()
9820 {
9821 return getInput(btnM, false, true);
9822 }
9823 bool DrunkcLbtn()
9824 {
9825 return getInput(btnL, false, true);
9826 }
9827 bool DrunkcRbtn()
9828 {
9829 return getInput(btnR, false, true);
9830 }
9831 bool DrunkcPbtn()
9832 {
9833 return getInput(btnP, false, true);
9834 }
9835
9836 bool DrunkrUp()
9837 {
9838 return getInput(btnUp, true, true);
9839 }
9840 bool DrunkrDown()
9841 {
9842 return getInput(btnDown, true, true);
9843 }
9844 bool DrunkrLeft()
9845 {
9846 return getInput(btnLeft, true, true);
9847 }
9848 bool DrunkrRight()
9849 {
9850 return getInput(btnRight, true, true);
9851 }
9852 2791110 bool DrunkrAbtn()
9853 {
9854 2791110 return getInput(btnA, true, true);
9855 }
9856 2781599 bool DrunkrBbtn()
9857 {
9858 2781599 return getInput(btnB, true, true);
9859 }
9860 71669 bool DrunkrEx1btn()
9861 {
9862 71669 return getInput(btnEx1, true, true);
9863 }
9864 71662 bool DrunkrEx2btn()
9865 {
9866 71662 return getInput(btnEx2, true, true);
9867 }
9868 bool DrunkrEx3btn()
9869 {
9870 return getInput(btnEx3, true, true);
9871 }
9872 bool DrunkrEx4btn()
9873 {
9874 return getInput(btnEx4, true, true);
9875 }
9876 bool DrunkrSbtn()
9877 {
9878 return getInput(btnS, true, true);
9879 }
9880 bool DrunkrMbtn()
9881 {
9882 return getInput(btnM, true, true);
9883 }
9884 3309626 bool DrunkrLbtn()
9885 {
9886 3309626 return getInput(btnL, true, true);
9887 }
9888 3307809 bool DrunkrRbtn()
9889 {
9890 3307809 return getInput(btnR, true, true);
9891 }
9892 bool DrunkrPbtn()
9893 {
9894 return getInput(btnP, true, true);
9895 }
9896
9897 4699 void eat_buttons()
9898 {
9899 4699 getInput(btnA, true, false, true);
9900 4699 getInput(btnB, true, false, true);
9901 4699 getInput(btnS, true, false, true);
9902 4699 getInput(btnM, true, false, true);
9903 4699 getInput(btnL, true, false, true);
9904 4699 getInput(btnR, true, false, true);
9905 4699 getInput(btnP, true, false, true);
9906 4699 getInput(btnEx1, true, false, true);
9907 4699 getInput(btnEx2, true, false, true);
9908 4699 getInput(btnEx3, true, false, true);
9909 4699 getInput(btnEx4, true, false, true);
9910 4699 }
9911
9912 // Is true for the _first frame_ of a key press.
9913 // But! it is possible that a script manually sets the value of KeyPress,
9914 // in which case it will be restored to the "true" value based on `key_current_frame`
9915 // and `key_previous_frame` on the next frame.
9916 14 bool zc_readkey(int32_t k, bool ignoreDisable)
9917 {
9918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(ignoreDisable) return KeyPress[k];
9919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 switch(k)
9920 {
9921 case KEY_F7:
9922 case KEY_F8:
9923 case KEY_F9:
9924 return KeyPress[k];
9925
9926 default:
9927
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 1 times.
14 return KeyPress[k] && !disabledKeys[k];
9928 }
9929 14 }
9930
9931 // Is true for _every frame_ a key is held down.
9932 // But! it is possible that a script manually sets the value of KeyInput,
9933 // in which case it will be restored to the "true" value based on `key_current_frame`
9934 // on the next frame.
9935 bool zc_getkey(int32_t k, bool ignoreDisable)
9936 {
9937 if(ignoreDisable) return KeyInput[k];
9938 switch(k)
9939 {
9940 case KEY_F7:
9941 case KEY_F8:
9942 case KEY_F9:
9943 return KeyInput[k];
9944
9945 default:
9946 return KeyInput[k] && !disabledKeys[k];
9947 }
9948 }
9949
9950 // Reads (and then clears) the current frame key state directly.
9951 // Scripts can also modify `key_current_frame`.
9952 28744547 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9953 {
9954
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 28744546 times.
28744547 if(zc_getrawkey(k, ignoreDisable))
9955 {
9956 1 _key[k]=key[k]=key_current_frame[k]=0;
9957 1 return true;
9958 }
9959 28744546 _key[k]=key[k]=key_current_frame[k]=0;
9960 28744546 return false;
9961 28744547 }
9962
9963 // Reads the current frame key state directly.
9964 // Scripts can also modify `key_current_frame`.
9965 56925193 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9966 {
9967
2/2
✓ Branch 0 taken 23789617 times.
✓ Branch 1 taken 33135576 times.
56925193 if(ignoreDisable) return key_current_frame[k];
9968
2/2
✓ Branch 0 taken 14372239 times.
✓ Branch 1 taken 18763337 times.
33135576 switch(k)
9969 {
9970 case KEY_F7:
9971 case KEY_F8:
9972 case KEY_F9:
9973 14372239 return key_current_frame[k];
9974
9975 default:
9976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18763337 times.
18763337 return key_current_frame[k] && !disabledKeys[k];
9977 }
9978 56925193 }
9979
9980 // Only used for a handful of keys, like tilde and Function keys.
9981 // This state is never read within the game.
9982 // It exists so that all keyboard input still functions during replay,
9983 // without inadvertently doing things like toggling throttling if the player
9984 // presses ~
9985 8658919 bool zc_get_system_key(int32_t k)
9986 {
9987 8658919 return key_system[k];
9988 }
9989
9990 // True for the _first_ frame of a key press.
9991 48301770 bool zc_read_system_key(int32_t k)
9992 {
9993 48301770 return key_system_press[k];
9994 }
9995
9996 557665890 bool is_system_key(int32_t k)
9997 {
9998
2/2
✓ Branch 0 taken 518146260 times.
✓ Branch 1 taken 39519630 times.
557665890 switch (k)
9999 {
10000 case KEY_BACKQUOTE:
10001 case KEY_CLOSEBRACE:
10002 case KEY_END:
10003 case KEY_HOME:
10004 case KEY_OPENBRACE:
10005 case KEY_PGDN:
10006 case KEY_PGUP:
10007 case KEY_TAB:
10008 case KEY_TILDE:
10009 39519630 return true;
10010 }
10011 518146260 return is_Fkey(k);
10012 557665890 }
10013
10014 4391070 void update_system_keys()
10015 {
10016 4391070 poll_keyboard();
10017
2/2
✓ Branch 0 taken 557665890 times.
✓ Branch 1 taken 4391070 times.
562056960 for (int32_t q = 0; q < 127; ++q)
10018 {
10019
2/2
✓ Branch 0 taken 92212470 times.
✓ Branch 1 taken 465453420 times.
557665890 if (!is_system_key(q))
10020 465453420 continue;
10021
10022 92212470 key_system[q] = key[q];
10023
1/2
✓ Branch 0 taken 92212470 times.
✗ Branch 1 not taken.
92212470 key_system_press[q] = key_system[q] && !key_system_previous[q];
10024 92212470 key_system_previous[q] = key_system[q];
10025 92212470 }
10026 4391070 }
10027
10028 5024136 void update_keys()
10029 {
10030
1/2
✓ Branch 0 taken 5024136 times.
✗ Branch 1 not taken.
5024136 if (!replay_is_replaying())
10031 poll_keyboard();
10032
10033
2/2
✓ Branch 0 taken 5024136 times.
✓ Branch 1 taken 638065272 times.
643089408 for (int32_t q = 0; q < 127; ++q)
10034 {
10035 // When replaying, replay.cpp takes care of updating `key_current_frame`.
10036
1/2
✓ Branch 0 taken 638065272 times.
✗ Branch 1 not taken.
638065272 if (!replay_is_replaying())
10037 key_current_frame[q] = key[q];
10038
10039
2/2
✓ Branch 0 taken 633766933 times.
✓ Branch 1 taken 4298339 times.
638065272 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
10040 638065272 KeyInput[q] = key_current_frame[q];
10041 638065272 key_previous_frame[q] = key_current_frame[q];
10042 638065272 }
10043 5024136 }
10044
10045 bool zc_disablekey(int32_t k, bool val)
10046 {
10047 switch(k)
10048 {
10049 case KEY_F7:
10050 case KEY_F8:
10051 case KEY_F9:
10052 return false;
10053
10054 default:
10055 disabledKeys[k] = val;
10056 return true;
10057 }
10058 }
10059
10060 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
10061 {
10062 timer=timer;
10063 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
10064 }
10065
10066 // these are here so that copy_dialog won't choke when compiling zelda
10067 int32_t d_alltriggerbutton_proc(int32_t, DIALOG*, int32_t)
10068 {
10069 return D_O_K;
10070 }
10071
10072 int32_t d_comboa_radio_proc(int32_t, DIALOG*, int32_t)
10073 {
10074 return D_O_K;
10075 }
10076
10077 int32_t d_comboabutton_proc(int32_t, DIALOG*, int32_t)
10078 {
10079 return D_O_K;
10080 }
10081
10082 int32_t d_ssdn_btn_proc(int32_t, DIALOG*, int32_t)
10083 {
10084 return D_O_K;
10085 }
10086
10087 int32_t d_ssdn_btn2_proc(int32_t, DIALOG*, int32_t)
10088 {
10089 return D_O_K;
10090 }
10091
10092 int32_t d_ssdn_btn3_proc(int32_t, DIALOG*, int32_t)
10093 {
10094 return D_O_K;
10095 }
10096
10097 int32_t d_ssdn_btn4_proc(int32_t, DIALOG*, int32_t)
10098 {
10099 return D_O_K;
10100 }
10101
10102 int32_t d_sslt_btn_proc(int32_t, DIALOG*, int32_t)
10103 {
10104 return D_O_K;
10105 }
10106
10107 int32_t d_sslt_btn2_proc(int32_t, DIALOG*, int32_t)
10108 {
10109 return D_O_K;
10110 }
10111
10112 int32_t d_sslt_btn3_proc(int32_t, DIALOG*, int32_t)
10113 {
10114 return D_O_K;
10115 }
10116
10117 int32_t d_sslt_btn4_proc(int32_t, DIALOG*, int32_t)
10118 {
10119 return D_O_K;
10120 }
10121
10122 int32_t d_ssrt_btn_proc(int32_t, DIALOG*, int32_t)
10123 {
10124 return D_O_K;
10125 }
10126
10127 int32_t d_ssrt_btn2_proc(int32_t, DIALOG*, int32_t)
10128 {
10129 return D_O_K;
10130 }
10131
10132 int32_t d_ssrt_btn3_proc(int32_t, DIALOG*, int32_t)
10133 {
10134 return D_O_K;
10135 }
10136
10137 int32_t d_ssrt_btn4_proc(int32_t, DIALOG*, int32_t)
10138 {
10139 return D_O_K;
10140 }
10141
10142 int32_t d_ssup_btn_proc(int32_t, DIALOG*, int32_t)
10143 {
10144 return D_O_K;
10145 }
10146
10147 int32_t d_ssup_btn2_proc(int32_t, DIALOG*, int32_t)
10148 {
10149 return D_O_K;
10150 }
10151
10152 int32_t d_ssup_btn3_proc(int32_t, DIALOG*, int32_t)
10153 {
10154 return D_O_K;
10155 }
10156
10157 int32_t d_ssup_btn4_proc(int32_t, DIALOG*, int32_t)
10158 {
10159 return D_O_K;
10160 }
10161
10162 int32_t d_tri_edit_proc(int32_t, DIALOG*, int32_t)
10163 {
10164 return D_O_K;
10165 }
10166
10167 int32_t d_triggerbutton_proc(int32_t, DIALOG*, int32_t)
10168 {
10169 return D_O_K;
10170 }
10171
10172 /*** end of zc_sys.cc ***/
10173
10174